1
votes

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

1
I don't believe that there is something similar in current JXLS. Why you cannot simply use the preferred way using JxlsHelper as described in jxls.sourceforge.net/samples/object_collection.html? Hint: OutputStream os might be a ByteArrayOutputStream too. - Axel Richter
Thanks for the answer! I've tried that implementation but I need to return an array of bytes, is there some way to get a byte[] from ByteArrayOutputStream after processing the template? - Paul

1 Answers

0
votes

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):

  • net/sf/jxls/parser/Cell.java
  • net/sf/jxls/parser/CellParser.java
  • net/sf/jxls/transformer/CellTransformer.java
  • net/sf/jxls/transformer/XLSTransformer.java
  • net/sf/jxls/util/TagBodyHelper.java
  • net/sf/jxls/util/Util.java

You need minor changes on them, e.g.:

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.