首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何设置Jasper使用XSSF?

如何设置Jasper使用XSSF?
EN

Stack Overflow用户
提问于 2015-12-08 04:32:06
回答 1查看 1.3K关注 0票数 2

在现有的系统中,已经使用Jasper5.0,据我所知,它使用poi HSSF来生成xls数据,但是现在随着应用程序的发展,报告出现了要生成的大计数事务的问题。

我已经搜索了解决方案,并使用XSSF找到了POI。因为JASPER也使用POI,所以我考虑在jasper内部使用XSSF。

这有可能吗?我怎么能这么做?我需要使用jasper,因为现在还不可能更改现有的应用程序。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-12-08 14:47:13

要导出jrxml生成ooxml XSSF,excel文件xlxs

使用net.sf.jasperreports.engine.export.ooxml.JRXlsxExporter

示例:

代码语言:javascript
复制
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

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34148050

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档