I'm making an application to analize some data and the result must be presented in excel files. In that sense I started to use Apache POI (3.11). Due to some reports consumes a lot of time and memory to be reproduce, I made an investigation and I found jxls, after some test I thought was the solution. But now I found a problem: can´t work both frameworks together.
- I have to update Apache POI from 3.11 to 3.14, in order to work with jxls-2.3.0
- I made an extra package in order to make my tests with jxls, not problem
I try to migrated one of my classes from Apache POI to jxls, and a I got this error:
java.lang.IllegalStateException: Cannot load XLS transformer. Please make sure a Transformer implementation is in classpath
. This is the code of my method:private void prepareNewReport(File excelFile) { List perforaciones = makePerforacionReport .makePerforacionData(escenario);
}try (InputStream is = ReportePerforacionTotalDialog.class .getResourceAsStream("PerforacionTotal_template.xls")){ try (OutputStream os = new FileOutputStream(excelFile)) { Context context = new Context(); context.putVar("perforaciones", perforaciones); JxlsHelper.getInstance().processTemplate(is, os, context); LOGGER.logger.log(Level.INFO, "Archivo de perfortacion generado con éxito"); } } catch (IOException e) { LOGGER.logger.log(Level.SEVERE, "Problemas buscando el archivo", e); }
How could be this possible?. In the same project I have my test class, just another package and its working fine. As you can see it´s not so much different from the example in the jxls page and the imports are the same.
But even worst, when I tried to make clean & build of my project, then I got this other error:
java.lang.RuntimeException: com.sun.tools.javac.code.Symbol$CompletionFailure: class file for org.openxmlformats.schemas.officeDocument.x2006.docPropsVTypes.CTArray not found
I looked at every library that I importede in order to work with jxls and apache poi, and that´s rigth, that class is not there. Just to see if there a conflict among these two framewoks, I eliminated from the class path all libraries needed to use jxls. Clean & build again, and not problem, I have my .jar file to send to my customer, but incomplete.
I could try to replace all classes that use Apache POI, but that means a lot of work, since POI is used in my project to read excel files with data many times and to write another many files to excel. I planned to use jxls in order to take advantage of use templates.
I will apreciate any help or suggestion.