I have one jrxml file that I would like to populate with 3 different datasources. Then I would like to export to an XLS or XLXS file with the 3 reports concatenated together on one sheet.
String input = "C:\\location\\report1.jrxml";
JasperReport jreport = JasperCompileManager.compileReport(input);
JasperPrint jprint1 = JasperFillManager.fillReport(jreport, new HashMap<String, Object>(), new JRBeanCollectionDataSource(getReportData(1)));
JasperPrint jprint2 = JasperFillManager.fillReport(jreport, new HashMap<String, Object>(), new JRBeanCollectionDataSource(getReportData(2)));
JasperPrint jprint3 = JasperFillManager.fillReport(jreport, new HashMap<String, Object>(), new JRBeanCollectionDataSource(getReportData(3)));
List<JasperPrint> jprintlist = new ArrayList<JasperPrint>();
jprintlist.add(jprint1);
jprintlist.add(jprint2);
jprintlist.add(jprint3);
JRXlsxExporter exporter = new JRXlsxExporter();
exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE);
exporter.setParameter(JRXlsExporterParameter.JASPER_PRINT_LIST, jprintlist);
String xlsFile = "C:\\location\\test.xlsx";
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, xlsFile);
exporter.exportReport();
The reports are all generating as I would expect, however in excel they are being generated on 3 different tabs, what I would like is to have them be built one on top of another. How can I merge them in this way?