在Excel中生成报告时,显示以下错误消息。请帮忙!!!
码:-
public String mainReportXLS(){
Map<String, Object> jrxmlParams = null;
try{
String jrxmlFileName = "C:/Jasper/Dashboard2.jrxml";
JasperReport objJReport = JasperCompileManager.compileReport(jrxmlFileName);
connection = getConnection();
JasperPrint print = JasperFillManager.fillReport(objJReport, jrxmlParams, connection);
ByteArrayOutputStream outputByteArray = new ByteArrayOutputStream();
//OutputStream outputfile= new FileOutputStream(new File("c:/output/JasperReport.xls"));
JRXlsExporter exporterXLS = new JRXlsExporter();
exporterXLS.setParameter(JRXlsExporterParameter.JASPER_PRINT, print);
exporterXLS.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, "C:/Jasper/Dashboard2.xls" );
exporterXLS.setParameter(JRXlsExporterParameter.OUTPUT_STREAM, outputByteArray);
exporterXLS.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE, Boolean.TRUE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
exporterXLS.exportReport();
//outputfile.write(outputByteArray.toByteArray());
}catch (Exception e) {
System.out.print("Exceptiion" + e);
}
return null;
}
Run Code Online (Sandbox Code Playgroud)
查看错误消息:-
]] Root cause of ServletException.
javax.faces.FacesException: Error calling …Run Code Online (Sandbox Code Playgroud) 尝试下面的代码,但不生成PDF报告.刚开始使用Jasper integartion.请帮忙.
public String mainReport() {
HashMap jrxmlParams = null;
try {
System.out.println("Start ....");
// Get jasper report
String jrxmlFileName = "C:/Jasper/DP_crosstabs.jrxml";
JasperReport objJReport = JasperCompileManager.compileReport(jrxmlFileName);
connection = getConnection();
jrxmlParams = new HashMap();
jrxmlParams.put("ID", "null");
JasperPrint objJPrint = JasperFillManager.fillReport(objJReport, jrxmlParams, connection);
ByteArrayOutputStream objBAOutputStream = new ByteArrayOutputStream();
JasperExportManager.exportReportToPdfStream(objJPrint, objBAOutputStream);
System.out.println("Done exporting reports to pdf");
} catch (Exception e) {
System.out.print("Exceptiion" + e);
}
return null;
}
Run Code Online (Sandbox Code Playgroud)