我用這個代碼報告導出爲的Excel文件,JasperReports的4.6:入門損壞的Excel與JasperReports的文件在Linux上
File reportFile = new File(externalContextAuthenticationConfiguration.getReportTempFolderUrl());
File outputFile = File.createTempFile("reportOutput", ".XLS", reportFile);
JRXlsExporter exporterXLS = new JRXlsExporter();
exporterXLS.setParameter(JRXlsExporterParameter.JASPER_PRINT, print);
exporterXLS.setParameter(JRXlsExporterParameter.OUTPUT_FILE, outputFile);
exporterXLS.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_COLLAPSE_ROW_SPAN, Boolean.TRUE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.TRUE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS, Boolean.TRUE);
exporterXLS.setParameter(JRXlsExporterParameter.CHARACTER_ENCODING, "UTF-8");
exporterXLS.exportReport();
return outputFile.getAbsolutePath();
這個代碼在Windows工作良好,但是當項目進展到了OpenSuse Linux中創建的Excel文件是這樣的畫面:
有誰知道問題是什麼?
你檢查結果文件,*微軟Office *? –
是的,當我用MS Office打開它也是損壞 – OmiD