CSV file formatting in JasperReports
I have a Jasper report with bunch of subreports. From what I can see all the subreports are aligned and have the same size, but when it generates the csv file the rows doesnt align with row properly
following is the example csv output
,A,,,,,B
,,B,,,X
,Z,,,,,E
File destFile = new File(csvFileName);
JRCsvExporter exporter = new JRCsvExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint1);
exporter.setParameter(JRExporte开发者_如何转开发rParameter.OUTPUT_FILE_NAME, destFile.toString());
exporter.exportReport();
I had a very similar problem, what logically should have been a single row ended up split across two rows in the CSV.
Despite CSV being a logical record structure, the CSV exporter still makes some attempt to map to the graphical layout of the report and will use rows and columns as spacer elements.
To ensure that all the items you wish to be in a a single row, make sure that the elements are all aligned with each other on their top edge. This solved my problem. Align them, recompile the report and all was well.
More information can be found here: http://fecplanner.com/jasperreports/docs/tips.tricks.html#friendly
精彩评论