How do you export a JasperReport to an Excel file with multiple worksheets?

后端 未结 3 2059
春和景丽
春和景丽 2020-12-06 01:21

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, bu

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-06 01:29

    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 list = new  ArrayList();
    list.add(jp1); list.add(jp2);
    exporter.setParameter(JRXlsExporterParameter.JASPER_PRINT_LIST, list);
    

    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.

提交回复
热议问题