CSV (Comma Separated Values) files contain a number of values separated by commas. There are several pieces of software that can parse CSV files. JasperReports includes built-in functionality to export reports to CSV files. The following example illustrates the process:
package net.ensode.jasperbook; import java.io.File; import net.sf.jasperreports.engine.JRException; import net.sf.jasperreports.engine.JRExporterParameter; import net.sf.jasperreports.engine.JasperPrint; import net.sf.jasperreports.engine.export.JRCsvExporter; import net.sf.jasperreports.engine.util.JRLoader; public class CsvExportDemo { public static final String REPORT_DIRECTORY = "reports"; public void csvExport(String reportName) { File file = new File(REPORT_DIRECTORY + "/" + reportName + ".jrprint"); try { JasperPrint jasperPrint = (JasperPrint) JRLoader.loadObject(file); JRCsvExporter csvExporter = new JRCsvExporter(); csvExporter.setParameter(JRExporterParameter. JASPER_PRINT...