我有一些麻烦将我的报告导出为XLS. PDF格式的导出效果很好.
所以我尝试更新到最新的JasperReports和Apache POI版本:
> JasperReports:5.5.0
> POI:3.7
> iText:2.1.7
但我总是收到以下异常:
java.lang.NoSuchMethodError: org.apache.poi.hssf.usermodel.HSSFWorkbook.createDataFormat()Lorg/apache/poi/hssf/usermodel/HSSFDataFormat;
net.sf.jasperreports.engine.export.JRXlsExporter.openWorkbook(JRXlsExporter.java:284)
net.sf.jasperreports.engine.export.JRXlsAbstractExporter.exportReportToStream(JRXlsAbstractExporter.java:927)
net.sf.jasperreports.engine.export.JRXlsAbstractExporter.exportReport(JRXlsAbstractExporter.java:697)
com.phoenix.customermonitor.print.GenericDataSourceApp.xls(GenericDataSourceApp.java:290)
com.phoenix.customermonitor.print.GenericDataSourceApp.exportToFormat(GenericDataSourceApp.java:335)
com.phoenix.core.JasperReportHandlerAction.exportOrderMonitorOverview(JasperReportHandlerAction.java:242)
com.phoenix.customermonitor.action.OrderMonitorMainAction.execute(OrderMonitorMainAction.java:217)
org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
javax.servlet.http.HttpServlet.service(HttpServlet.java:643)
javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
出口代码
File sourceFile = new File(fileIn);
JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile);
String name = fileIn.substring(fileIn.lastIndexOf(System.getProperty("file.separator"))+1);
name = name.substring(0, name.lastIndexOf("."));
File destFile = new File(fileOut);
JRXlsExporter exporter = new JRXlsExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, destFile.toString());
exporter.exportReport();
经过一些研究,我尝试了其他几个版本(4),但我仍然收到此错误.有谁知道解决方案?