I’m using jasper report v. 6.17.0 to generate reports and apache poi - 4.1.2 , poi-ooxml- 4.1.2, ooxml-schemas- 1.4 and poi-ooxml-schemas- 4.1.2 In order to exports the generated reports in pdf, docs, xls and xlsx format. Only the xls format is not working
the code is mentioned below
JRAbstractExporter exporter = new JRXlsExporter();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
// Here we assign the parameters jp and baos to the exporter
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos);
if(ReportOutputType.XLS.equals(reportOutputType) || ReportOutputType.XLSX.equals(reportOutputType)){
exporter.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE, Boolean.TRUE);
exporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
exporter.setParameter(JRXlsExporterParameter.IS_IGNORE_GRAPHICS, Boolean.FALSE);
exporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS, Boolean.TRUE);
exporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
exporter.setParameter(JRXlsExporterParameter.IS_COLLAPSE_ROW_SPAN, Boolean.TRUE);
exporter.setParameter(JRXlsExporterParameter.IS_FONT_SIZE_FIX_ENABLED, Boolean.TRUE);
exporter.setParameter(JRXlsExporterParameter.IS_IGNORE_CELL_BORDER, Boolean.TRUE);
}
try {
exporter.exportReport();
} catch (JRException e) {
throw new RuntimeException(e);
}
return baos;
Here as soon as the instance of JRXLSexporter() is executed then I get the exception as -
Caused by: java.lang.NoClassDefFoundError: org/apache/poi/hssf/util/HSSFColor$WHITE
at deployment.dp.war//net.sf.jasperreports.engine.export.JRXlsExporter.<init>(JRXlsExporter.java:163)
at deployment.dp.war//net.sf.jasperreports.engine.export.JRXlsExporter.<init>(JRXlsExporter.java:191)
at deployment.dp.war//com.apc.dp.view.utils.exports.ReportsExporter.getReportOutputType(ReportsExporter.java:56)
at deployment.dp.war//com.apc.dp.view.utils.exports.ReportsExporter.<init>(ReportsExporter.java:74)
at deployment.dp.war//com.apc.dp.controller.solution.SolutionReportsController.getPartNumberReports(SolutionReportsController.java:963)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at deployment.dp.war//org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
at deployment.dp.war//org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)
at deployment.dp.war//org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)
at deployment.dp.war//org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
at deployment.dp.war//org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
at deployment.dp.war//org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at deployment.dp.war//org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067)
... 56 more
Caused by: java.lang.ClassNotFoundException: org.apache.poi.hssf.util.HSSFColor$WHITE from [Module "deployment.dp.war" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:255)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:410)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
... 72 more
I followed the articles where they advice to keep the jar files in the classpath but none of them worked. I tried updating the poi jars to latest version that also didn’t help.Please see my entirepom.xml and suggest accordingly. pom.xml link - https://www.dropbox.com/scl/fi/sisa9236nb5m4dx75gtc2/pom.paper?dl=0&rlkey=hr73iolribgw3e5xvu6a08y4s