Jump to content
Changes to the Jaspersoft community edition download ×

Export to Excel, CSV


2005 IR Help

Recommended Posts

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

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...