Jasper Reports - Export to CSV includes multiple headers and footers
Luis Palacios
VP, Engineering - Rego Consulting | Director of Engineering - Moventus | CTO - Relevus Technology
After a series of articles related to JasperReports, there's been a recurring issue reported by customers and contacts. When exporting to CSV the titles, footers, and/or the column headers are repeated across the document. Which basically defeats the ease of use for CSV files to load them into external systems, filter them or open them in Excel.
When building custom reports, the following properties can be added to the jrxml via JasperStudio or by exporting the report, modifying the files and uploading back via the UI (for more information on how to use properties refer to https://community.jaspersoft.com/wiki/properties-how-use-additional-properties-build-enhanced-reports):
<!--hide footers and headers, except for firt page -->
<property name="net.sf.jasperreports.export.csv.exclude.origin.keep.first.band.1" value="pageHeader"/>
<property name="net.sf.jasperreports.export.csv.exclude.origin.band.2" value="pageFooter"/>
<property name="net.sf.jasperreports.export.csv.exclude.origin.keep.first.band.3=" value="olumnHeader"/>
<property name="net.sf.jasperreports.export.csv.exclude.origin.keep.first.report.3" value="*"/>
<property name="net.sf.jasperreports.export.csv.exclude.origin.band.4" value="columnFooter"/>
Clarity consultant at ITROI Solutions
6 年It works great!! An easy and fast solution