2005 IR Help Posted August 26, 2006 Share Posted August 26, 2006 By: Ruben Misrahi - rnmisrahi Export to Excel, CSV 2004-08-03 06:32 Is there an easy way to export to Excel or CSV? I mean, as simple as exporting to pdf, html. By: krishna tummeti - vtummeti RE: Export to Excel, CSV 2004-08-04 16:05 Here are the two method samples that generate the reports in Excel and CSV formats public String xls(String filename, String dest_filename){ try{ File sourceFile = new File(filename); JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile); File destFile = new File(dest_filename); JRXlsExporter exporter = new JRXlsExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, destFile.toString()); exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE); exporter.exportReport(); } catch(Throwable t){return "error: " + t.getMessage();} return "XLS Report generated Successfully!"; } public String csv(String filename, String dest_filename){ try{ File sourceFile = new File(filename); JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile); File destFile = new File(dest_filename); JRCsvExporter exporter = new JRCsvExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, destFile.toString()); exporter.exportReport(); } catch(Throwable t){return "error: " + t.getMessage();} return "CSV Report generated Successfully!"; } - Krishna Tummeti Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now