[英]javax.el.ELException: java.lang.NoClassDefFoundError: jxl/read/biff/BiffException
In a JSF 2.x application, I'm using PrimeFaces V-3.5 and JasperReports V-5.2 . 在JSF 2.x应用程序中,我使用的是PrimeFaces V-3.5和JasperReports V-5.2 。 I am trying to export some reports with JasperReports . 我正在尝试使用JasperReports导出一些报告。 I am able to export report in PDF and RTF format; 我能够导出PDF和RTF格式的报告; however, Excel format does not work and I encounter error as the following: 但是, Excel格式不起作用,并且遇到以下错误:
javax.el.ELException: java.lang.NoClassDefFoundError: jxl/read/biff/BiffException
Here is my report generator method: 这是我的报告生成器方法:
private void prepareReport(String reportPath, @SuppressWarnings("rawtypes") List beanList, String outputFormat, String reportName) {
JasperReport jReport = null;
JasperPrint jPrint = null;
try {
jReport = JasperCompileManager.compileReport(reportPath);
jPrint = JasperFillManager.fillReport(jReport, jasperParameter, new JRBeanCollectionDataSource(beanList));
} catch (JRException e) {
e.printStackTrace();
}
FacesContext ctx = FacesContext.getCurrentInstance();
HttpServletResponse response = (HttpServletResponse) ctx.getExternalContext().getResponse();
OutputStream outputStream = null;
try {
outputStream = response.getOutputStream();
} catch (IOException e) {
e.printStackTrace();
}
try {
if (outputFormat.equals(OUTPUT_FORMAT_PDF)) {
response.setContentType("application/pdf");
response.setHeader("Content-disposition", "attachment; filename=" + reportName + ".pdf");
JasperExportManager.exportReportToPdfStream(jPrint, outputStream);
} else if (outputFormat.equals(OUTPUT_FORMAT_EXCEL)) {
response.setContentType("application/xls");
response.setHeader("Content-disposition", "attachment; filename=" + reportName + ".xls");
JExcelApiExporter exporter = new JExcelApiExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, outputStream);
exporter.exportReport();
} else if (outputFormat.equals(OUTPUT_FORMAT_RTF)) {
response.setContentType("application/rtf");
response.setHeader("Content-disposition", "attachment; filename=" + reportName + ".rtf");
JRRtfExporter exporter = new JRRtfExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, outputStream);
exporter.exportReport();
}
} catch (JRException e) {
e.printStackTrace();
}
try {
outputStream.flush();
outputStream.close();
FacesContext.getCurrentInstance().responseComplete();
} catch (IOException e) {
e.printStackTrace();
}
}
How can I export report in Excel format? 如何导出Excel格式的报告?
You are using the JExcelApiExporter . 您正在使用JExcelApiExporter 。 It is using the JExcelApi library. 它正在使用JExcelApi库。
You can check the dependency in the JasperReports 's pom.xml file. 您可以在JasperReports的pom.xml文件中检查依赖性。 The JasperReports 5.2 is using this artifact: JasperReports 5.2正在使用此工件:
<dependency>
<groupId>net.sourceforge.jexcelapi</groupId>
<artifactId>jxl</artifactId>
<version>2.6.10</version>
</dependency>
It means that you should add jxl-2.6.10.jar to your application classpath (in case using JasperReports 5.2 ). 这意味着您应该将jxl-2.6.10.jar添加到您的应用程序类路径中(如果使用JasperReports 5.2 )。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.