1

I have two subreports, which are in separate worksheets. The problem is, that the column segmantation in the second worksheet is the same as in the first and so there are some merged cells. With merged cells you could not sort the columns ("This operation requires the merged cells to be identically sized").

How could I enforce a new style/segmentation of the columns?

These are my settings for the exporter:

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

Output from second report (cmp.subreport(secondReportBuilder)) Output from second report I would expect, that there are only two columns (A-B) and not A-G.

knobli
  • 657
  • 1
  • 9
  • 18
  • You like the cells not to be merged?, xlsxExporter.setCollapseRowSpan(true);, maybe a screen shot of the problem in excel, shows what you like to achieve.. – Petter Friberg Dec 04 '15 at 10:18
  • Which call is this, cmp.subreport(secondReportBuilder)?, are you using jrxml template here?, or only dynamic jasper (if only Dynamic Jasper, check how your columns is set up..). I think i would have chosen a solution without sub report, adding the different reports 1 by 1 to different sheets.. – Petter Friberg Dec 04 '15 at 11:23
  • Yes it's the second one and no there is no jxrml template, but if it helps, I could add one. Could you please give me an example for "adding the different reports 1 by 1 to different sheets" – knobli Dec 04 '15 at 11:56
  • 1
    Generate multiple JasperPrint, and them to the standard JRPdfExporter and export... Check out this http://stackoverflow.com/questions/3977658/how-do-you-export-a-jasperreport-to-an-excel-file-with-multiple-worksheets/ – Petter Friberg Dec 04 '15 at 12:36
  • Great that's it, with multiple JasperPrints it works – knobli Dec 04 '15 at 14:19

1 Answers1

1

Converting comment to answer:

Generate multiple JasperPrint from DynamicJasper and then use the standard JRXlsExporter

JRXlsExporter exporter = new JRXlsExporter();
List<JasperPrint> sheets = new ArrayList<JasperPrint>();
sheets.add(criteriaReportBuilder.toJasperPrint());
sheets.add(reportBuilder.toJasperPrint());
exporter.setExporterInput(SimpleExporterInput.getInstance(sheets));
...
knobli
  • 657
  • 1
  • 9
  • 18
Petter Friberg
  • 21,252
  • 9
  • 60
  • 109