我需要在JasperReports
中導出爲excel和csv格式。對於excel,我嘗試了使用JRXlsExporter
類,但它不是導出。事情是與「保存和取消」彈出窗口與文件類型未知的未來..如何在JasperReports中導出爲excel?
file type like "getReportDetail.do"
其中getReportDetail.do
是「路徑」屬性中配置XML支柱的「動作」元素。我打電話給這個getReportDetail.do
通過點擊html按鈕來調用「action class」來導出excel。
我設置參數如下圖所示
reportExporter.setParameter(JRXlsExporterParameter.JASPER_PRINT, jasperPrint);
reportExporter.setParameter(JRXlsExporterParameter.OUTPUT_STREAM, reportStream);
reportExporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
reportExporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE);
reportExporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
reportExporter.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE, Boolean.TRUE);
其中reportStream
是ByteArrayOutputStream()
對象,
reportExporter
是JRXlsExporter
對象
和contenttype
是response.setContentType("application/xls");
任何想法,爲什麼它是發生了什麼?
試着將文件保存到文件系統首先看是否生成的報告很糟糕,或者之後發生的情況。 – 2010-09-17 16:52:25