I have some troubles to export my report as XLS. The export as PDF works well.
So I tried to update to the latest JasperReports and Apache POI version:
But I receive always following exception:
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)
Export Code
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();
After some researches I tried several other Versions(+4) but I still receive this error. Does anyone know a solution?
You have an old version library in your class path.
If the jasper report depends on lib-xxx.jar, then make sure that there are no other lib-yyy.jar in your class path. You can do this by reviewing the jasper downloaded jar or pom.xm.
As I can guess there are some old versions of poi in your class path.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With