Jasper Soft Excel列问题

时间:2015-12-16 10:58:12

标签: jasper-reports

我有8个子报告放在主报告上 “print.one .page.per.sheet”已启用。 并在每个子报告启用net.sf.jasperreports.export.xls.break.after.row属性后(用于在新工作表中打印每个子报告) 将每个报告单独导出到Excel时,Excel工作表中的每个列都与报告的列匹配。 但是将它放在主报表中后,excel列与报表列重叠。 如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

使用excel将各个子报表放在不同表格中的一个解决方案是不使用主报表,而是将不同子报表的JasperPrint作为不同的表格传递。

示例

List<JasperPrint> sheets = new ArrayList<JasperPrint>();
for (int i=1;i<=8;i++){
   JasperPrint print = JasperFillManager.fillReport("subReport_" + i + ".jasper", paramMap, connection);
   sheets.add(print); 
}

JRXlsxExporter exporter = new JRXlsxExporter();
exporter.setExporterInput(SimpleExporterInput.getInstance(sheets));
exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(new File("text.xlxs"));
SimpleXlsxReportConfiguration configuration = new SimpleXlsxReportConfiguration();
configuration.setSheetNames(sheetNames): //sheets names is an array of the different names.
configuration.setDetectCellType(true);
configuration.setWhitePageBackground(false);
configuration.setRemoveEmptySpaceBetweenColumns(true);
configuration.setRemoveEmptySpaceBetweenRows(true);
exporter.setConfiguration(configuration);
exporter.exportReport();