I need to know if those libraries mentioned in the title are compatible between each other. What I need to do is to change libraries: from net.sf.jxls to org.jxls 2.10.0 (and therefore adapt the implementation that was made using jxls-core 1.0.6 ). I'm working with java 8.
According to the implementation that I need to adapt, jxls is used by first instanciating and XLSTransformer object: XLSTransformer transformer = new XLSTransformer(); Then, the method ' transformXLS(...) ' is called which receives an InputStream as parameter and a Map, and returns a Workbook object .
Is there a similar method or some kind of 'work-around' in jxls 2.10.0 to perform exactly the same? What I need to know is a way to return a Workbook object using jxls 2.10.0 in order to adapt the implementation done with jxls-core 1.0.6
While jxls1 does not directly support POI4, it is easy to modify it for this purpose.
You basically have to edit these classes (in jxls-core):
You need minor changes on them, eg:
XLSTransformer.java: line 484, change
if (cell != null && cell.getCellType() == Cell.CELL_TYPE_STRING) {
to
if (cell != null && cell.getCellType() == CellType.STRING) {
so basically all changes are minor changes. You can find the jxls1 code with POI 4 support here: https://github.com/infofabrik/reportserver/tree/main/jxls-src
We are also working on sending this code to the jxls team. But you can of course use the classes available in the link.
I also recently upgraded from 1.x to 2.x of JXLS and ran into this issue. I used this code to take an input stream of an Excel file, then process the template with a Map of <String, Object> entries, and finally retrieve the workbook.
PoiTransformer transformer = PoiTransformer.createTransformer(is);
JxlsHelper.getInstance().processTemplate(new Context(yourStringObjectMap), transformer);
Workbook workbook = transformer.getWorkbook();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.