如何将JasperReport导出到具有多个工作表的Excel文件? [英] How do you export a JasperReport to an Excel file with multiple worksheets?

查看:304
本文介绍了如何将JasperReport导出到具有多个工作表的Excel文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个报告,客户希望导出到具有多个工作表的Excel格式。基本上这两个查询共享相同的参数,但其他一切都是不同的。

We have a report that the customer would like to have exported to an excel format where it has multiple worksheets. Essentially the two queries share the same parameters, but everything else is different.

在jasper报告中,如何导出到具有多个工作表的Excel文件(理想情况下来自不同的数据源)?

推荐答案

感谢这个线程,我使用多个工作表创建Excel导出更加容易。我发现,你可以使用以下内容:

Thanks to this thread it really was easier for me to create an Excel export with multiple sheets. What I found out was that you could use the following:

ArrayList<JasperPrint> list = new  ArrayList<JasperPrint>();
list.add(jp1); list.add(jp2);
exporter.setParameter(JRXlsExporterParameter.JASPER_PRINT_LIST, list);

,导出器将自动使用每个JasperPrint对象来构建每个工作表; Jasper报告的名称(在jrxml文件中指定)也被用作每个工作表的名称。

and the exporter will automatically use every JasperPrint object to construct each sheet; also the name of the Jasper report (as specified in the jrxml file) is used as the name of each sheet.

目前,该解决方案适用于我的本地项目,所以我只是想让你知道。

Currently this solution works on my local project, so I just wanted to let you know.

这篇关于如何将JasperReport导出到具有多个工作表的Excel文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆