在现有的系统中,已经使用Jasper5.0,据我所知,它使用poi HSSF来生成xls数据,但是现在随着应用程序的发展,报告出现了要生成的大计数事务的问题。
我已经搜索了解决方案,并使用XSSF找到了POI。因为JASPER也使用POI,所以我考虑在jasper内部使用XSSF。
这有可能吗?我怎么能这么做?我需要使用jasper,因为现在还不可能更改现有的应用程序。
发布于 2015-12-08 14:47:13
要导出jrxml生成ooxml XSSF,excel文件xlxs
使用net.sf.jasperreports.engine.export.ooxml.JRXlsxExporter
示例:
JasperPrint jasperPrint = JasperFillManager.fillReport(report, paramMap, connection); //Example of how to get the jasper print
JRXlsxExporter exporter = new JRXlsxExporter();
exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
File outputFile = new File("excelTest.xlsx");
exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(outputFile));
SimpleXlsxReportConfiguration configuration = new SimpleXlsxReportConfiguration();
configuration.setOnePagePerSheet(false); //Set configuration as you like it!!
configuration.setDetectCellType(true);
configuration.setCollapseRowSpan(false);
exporter.setConfiguration(configuration);
exporter.exportReport();当然,您需要类路径中的相关库(poi-ooxml.jar、poi-ooxml-schemas.jar、xmlbeans.jar),它们存在于jasper的分发中。
JRXlsxExporter是从4.5版开始提供的,这是jasper report 5.5.0 API。在版本4参数中,设置而不是属性,请参见jasperreports-export not xls
https://stackoverflow.com/questions/34148050
复制相似问题