gradleapache-poijxls

jxls 2.5 compacibility for using jxls-poi-1.0.12


I am using jxls-poi-1.0.12. After jxls 2.5 release, gradle auto updated the jxls to 2.5. For the result I got an exception when running JxlsHelper.getInstance().processTemplate(context, transformer)

java.lang.AbstractMethodError: org.jxls.transform.poi.PoiTransformer.adjustTableSize(Lorg/jxls/common/CellRef;Lorg/jxls/common/Size;)V
at org.jxls.command.EachCommand.applyAt(EachCommand.java:262)
at org.jxls.area.XlsArea.applyAt(XlsArea.java:172)
at org.jxls.command.EachCommand.processCollection(EachCommand.java:296)
at org.jxls.command.EachCommand.applyAt(EachCommand.java:255)
at org.jxls.area.XlsArea.applyAt(XlsArea.java:172)

I checked jxls 2.5 update. I find when EachCommand running, jxls 2.5 added adjustTableSize() method to transformer interface. However, PoiTransformer has not implement this method so I got this error. That means jxls 2.5 don't have compacibility for jxls-poi-1.0.12.

Of cause, I can upgrade my poi but it takes many time. Is that possible to downgrade my jxls or disable to run Transformer.adjustTableSize()?

Here is my build.gradle

compile group: 'org.jxls', name: 'jxls-jexcel', version: '1.0.6'
compile group: 'org.jxls', name: 'jxls-poi', version: '1.0.12'
compile group: 'org.jxls', name:'jxls', version :'2.4.0'

Solution

  • We had encountered same issue today. After investigation, we found the way to solve it. so please let me share.

    please try to change the gradle.build as below.

    compile ("org.jxls:jxls-poi:1.0.12"){
        transitive = false
      }
    

    once you change, gradle will ignore the dependencies which jxls-poi specifying.

    please see the document in detail. (this document is for gradle 4.10, but we tested gradle 3.x) https://docs.gradle.org/4.10/userguide/managing_transitive_dependencies.html#sub:disabling_resolution_transitive_dependencies


    this is because jxls-poi's version setting. here is the specification of POI's Dependency Version Requirement Specification.

    https://maven.apache.org/pom.html#Dependency_Version_Requirement_Specification

    so, org.jxls:jxls:[2.4.0,) means use 2.4.0 or later.

    # this is the part of result of gradle dependencies command.
    ...
    +--- org.jxls:jxls-poi:1.0.12
    |    |    +--- org.jxls:jxls:[2.4.0,) -> 2.5.0 (*)
    ...
    

    once you exclude jxls-poi's setting, jxls's version will be changed to the specified version.

    before

    |    +--- org.jxls:jxls:2.4.0 -> 2.5.0 (*)
    

    after(solved)

    |    +--- org.jxls:jxls:2.4.0 (*)