I have this code to export a JasperReprot to XLS:
JasperPrint jprint=JasperFillManager.fillReport(expRpg, null, new JRBeanCollectionDataSource(datali
Here is my CODE:
String sourceFileName = "./jasper_report_template.jasper";
Map parameters = new HashMap();
String printFileName = null;
try {
printFileName = JasperFillManager.fillReportToFile(sourceFileName, parameters, beanArrayDataSource);
if(printFileName != null){
//JasperPrintManager.printReport( printFileName, true);
/** 1- export to PDF*/
JasperExportManager.exportReportToPdfFile(printFileName,
"C://Users/zanderkong/Desktop/sample_report.pdf");
/**3- export to Excel sheet*/
RXlsExporter xlsExporter = new JRXlsExporter();
xlsExporter.setExporterInput(new SimpleExporterInput(printFileName));
xlsExporter.setExporterOutput(new SimpleOutputStreamExporterOutput("C://Users/zanderkong/Desktop/sample_report.xls"));
SimpleXlsReportConfiguration configuration = new SimpleXlsReportConfiguration();
configuration.setOnePagePerSheet(true);
configuration.setDetectCellType(true);
configuration.setCollapseRowSpan(false);
xlsExporter.setConfiguration(configuration);
xlsExporter.exportReport();
}
} catch (JRException e) {
e.printStackTrace();
}