我使用的是jxls-poi-1.0.12。在jxls 2.5发布后,gradle auto将jxls更新为2.5。对于结果,我在运行JxlsHelper.getInstance().processTemplate(context,转换器时得到了一个异常)
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)我检查了jxls 2.5更新。我发现当EachCommand运行时,jxls 2.5将adjustTableSize()方法添加到转换器接口中。但是,PoiTransformer还没有实现这个方法,所以我得到了这个错误。这意味着jxls 2.5不具有jxls-poi-1.0.12的可组合性。
当然,我可以升级我的poi,但这需要很多时间。这有可能降低jxls的级别或禁用运行Transformer.adjustTableSize()吗?
这是我的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'发布于 2019-02-15 06:23:31
我们今天也遇到了同样的问题。经过调查,我们找到了解决这个问题的方法。所以请让我分享一下。
请按以下方式更改gradle.build。
compile ("org.jxls:jxls-poi:1.0.12"){
transitive = false
}一旦更改,gradle将忽略jxls-poi指定的依赖项。
请详细查看这份文件。(本文档用于gradle 4.10,但我们测试了gradle 3.x) dependencies
这是因为jxls-poi的版本设置。以下是POI的依赖版本需求规范的规范。
因此,org.jxls:jxls:[2.4.0,)的意思是使用2.4.0或更高版本。
# 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 (*)
...一旦排除jxls-poi的设置,jxls的版本将更改为指定的版本。
在此之前
| +--- org.jxls:jxls:2.4.0 -> 2.5.0 (*)在(解决)之后
| +--- org.jxls:jxls:2.4.0 (*)发布于 2019-02-14 20:18:21
为了能够在Apache中使用Jxls 2.5.0,您必须切换到jxls-poi 1.1.0,后者实现了Transformer.adjustTableSize()。
如果您不想使用最新的POI版本,可以尝试从jxls-poi依赖项中排除它,并使用旧的POI版本,但是,如果POI版本之间发生了中断的API更改,则这可能无法工作。
更新16.02.2019: Jxls 2.5.1版本现已发布。该版本应该向后兼容jxls-poi 1.0.x版本,因此当该版本在Maven Central中可用时,问题就会消失。
发布于 2019-02-15 13:14:01
上面说的话是有道理的,但不完全正确。
compile("org.jxls:jxls-poi:1.0.15"){
transitive = false
}
compile("org.jxls:jxls:2.4.0")https://stackoverflow.com/questions/54686398
复制相似问题