Jump to content
Changes to the Jaspersoft community edition download ×

Adding XLS to PDF and HTML reports


Chief

Recommended Posts

Hello,

 

I'm adding XLS to an existing reports setup that works perfectly for PDF and HTML reports.

 

The code I'm working with is:

Code:

public String generateReport(String reportname, int outputtype, Map props){
String filename = null;
props.put("outputdir",outputdir);
props.put("inputdir",inputdir);
props.put("filetype",ReportGenerator.getTypeName(outputtype));
try {
JasperPrint print = JasperFillManager.fillReport(inputdir+"/"+reportname+".jasper",props,db);

switch(outputtype){
case HTML_TYPE:
filename = outputdir+"/"+reportname+"-"+System.currentTimeMillis()+".html";
JasperExportManager.exportReportToHtmlFile(print,filename);
break;
case PDF_TYPE:
filename = outputdir+"/"+reportname+"-"+System.currentTimeMillis()+".pdf";
JasperExportManager.exportReportToPdfFile(print,filename);
break;
case XLS_TYPE:
JRXlsExporter exporter = new JRXlsExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, filename );
exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.TRUE);
exporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
exporter.exportReport();
break;

}
}
catch (JRException e){
System.out.println("An error occured loading the report."«»);
e.printStackTrace();
System.exit(-1);
}

return filename;
}

 

The HTML and PDF work great but the XLS gives:

 

net.sf.jasperreports.engine.JRException: No output specified for the exporter.

at net.sf.jasperreports.engine.export.JRXlsAbstractExporter.exportReport(JRXlsAbstractExporter.java:151)

ports.ReportGenerator.main(ReportGenerator.java:158)

 

 

Is there something simple I'm missing? Any and all help is appreciated!

Link to comment
Share on other sites

  • Replies 1
  • 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...