使用 JasperXlsxExporterBuilder 在工作表中进行不同的列分割
Different column segmentation in worksheets with JasperXlsxExporterBuilder
我有两个子报表,它们位于不同的工作表中。问题是,第二个工作表中的列分割与第一个工作表中的列分割相同,因此存在一些合并的单元格。对于合并的单元格,您无法对列进行排序 ("This operation requires the merged cells to be identically sized")。
如何强制执行新的 style/segmentation 列?
这些是我对导出器的设置:
reportBuilder.title(cmp.subreport(criteriaReportBuilder), cmp.subreport(secondReportBuilder));
JasperXlsxExporterBuilder xlsxExporter = DynamicReports.export.xlsxExporter(outputStream);
xlsxExporter.setCollapseRowSpan(false);
xlsxExporter.setRemoveEmptySpaceBetweenColumns(true);
xlsxExporter.setRemoveEmptySpaceBetweenRows(false);
xlsxExporter.setDetectCellType(true);
xlsxExporter.setWhitePageBackground(false);
xlsxExporter.setIgnoreGraphics(false);
xlsxExporter.setOnePagePerSheet(false);
reportBuilder.toXlsx(xlsxExporter);
第二份报告的输出 (cmp.subreport(secondReportBuilder))
我希望只有两列 (A-B) 而不是 A-G。
正在将评论转换为答案:
从DynamicJasper
生成多个JasperPrint
然后使用标准JRXlsExporter
JRXlsExporter exporter = new JRXlsExporter();
List<JasperPrint> sheets = new ArrayList<JasperPrint>();
sheets.add(criteriaReportBuilder.toJasperPrint());
sheets.add(reportBuilder.toJasperPrint());
exporter.setExporterInput(SimpleExporterInput.getInstance(sheets));
...
我有两个子报表,它们位于不同的工作表中。问题是,第二个工作表中的列分割与第一个工作表中的列分割相同,因此存在一些合并的单元格。对于合并的单元格,您无法对列进行排序 ("This operation requires the merged cells to be identically sized")。
如何强制执行新的 style/segmentation 列?
这些是我对导出器的设置:
reportBuilder.title(cmp.subreport(criteriaReportBuilder), cmp.subreport(secondReportBuilder));
JasperXlsxExporterBuilder xlsxExporter = DynamicReports.export.xlsxExporter(outputStream);
xlsxExporter.setCollapseRowSpan(false);
xlsxExporter.setRemoveEmptySpaceBetweenColumns(true);
xlsxExporter.setRemoveEmptySpaceBetweenRows(false);
xlsxExporter.setDetectCellType(true);
xlsxExporter.setWhitePageBackground(false);
xlsxExporter.setIgnoreGraphics(false);
xlsxExporter.setOnePagePerSheet(false);
reportBuilder.toXlsx(xlsxExporter);
第二份报告的输出 (cmp.subreport(secondReportBuilder))
正在将评论转换为答案:
从DynamicJasper
生成多个JasperPrint
然后使用标准JRXlsExporter
JRXlsExporter exporter = new JRXlsExporter();
List<JasperPrint> sheets = new ArrayList<JasperPrint>();
sheets.add(criteriaReportBuilder.toJasperPrint());
sheets.add(reportBuilder.toJasperPrint());
exporter.setExporterInput(SimpleExporterInput.getInstance(sheets));
...