Jump to content
Changes to the Jaspersoft community edition download ×

How to generate XLS(Excel) file in java using jrxml?


abbhiseth

Recommended Posts

 

The following is the code for report generation of Excel(XLS) report using JAVA JRXML.Its generating a blank file.I am calling the method by this:
 
String hello=xls(JRXML_FILE, PDF_FILE, JASPER_FILE);
Where JRXML_FILE is the poath of JRXML file
Where PDF_FILE is the destination path of the Excel  file
JASPER_FILE is the link to the JASPER file.
PLS HELP!
 
 
public String xls(String filename, String dest_filename, String jasper_file){ try{ //File sourceFile = new File(filename); //HashMap hm = new HashMap();         // JasperPrint print = JasperFillManager.fillReport(filename, hm, new JREmptyDataSource());  1JasperCompileManager.compileReportToFile(filename, jasper_file);File sourceFile = new File(jasper_file);  JasperReport jasperReport = (JasperReport) JRLoader.loadObject(sourceFile);  JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, new HashMap<String, Object>());   File destFile = new File(dest_filename);  JRXlsExporter exporter = new JRXlsExporter();  exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.TRUE);exporter.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE, Boolean.TRUE);exporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);exporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);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!"; } 

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...