2

In a existing system already use jasper 5.0 and as I know it use poi HSSF to generate xls data, but now as the application grow up, the report have a problem with a big count transaction to generate.

I have search for the solution and found POI with XSSF. Because jasper use POI HSSF too, I thinking about to use XSSF inside of JASPER.

Is that possible? and how I could do that? I need to use jasper because it's not possible for now to change the existing app.

Petter Friberg
  • 21,252
  • 9
  • 60
  • 109
Angripa
  • 159
  • 2
  • 4
  • 14

1 Answers1

3

To export jrxml generating ooxml XSSF, excel file xlxs

Use the net.sf.jasperreports.engine.export.ooxml.JRXlsxExporter

Example:

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();

Naturally you need related libraries (poi-ooxml.jar, poi-ooxml-schemas.jar, xmlbeans.jar) in your classpath, they are present in the distribution of jasper report.

The JRXlsxExporter is available since version 4.5 this is the jasper report 5.5.0 API. In version 4 parameters where set instead of properties please see jasperreports-export-to-xlsx-not-xls

Community
  • 1
  • 1
Petter Friberg
  • 21,252
  • 9
  • 60
  • 109