I'm trying to make work a piece of code to read a docx file, but it fails for some strange reason.
It fails on this line:
XWPFDocument document = new XWPFDocument(new FileInputStream(filepath));
Stack trace:
Exception in thread "main" java.lang.NoSuchMethodError: org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl.getTrList()Ljava/util/List;
at org.apache.poi.xwpf.usermodel.XWPFTable.<init>(XWPFTable.java:106)
at org.apache.poi.xwpf.usermodel.XWPFDocument.onDocumentRead(XWPFDocument.java:151)
at org.apache.poi.POIXMLDocument.load(POIXMLDocument.java:159)
at org.apache.poi.xwpf.usermodel.XWPFDocument.<init>(XWPFDocument.java:124)
at helper.JavaHelper.readTableDataFull(JavaHelper.java:84)
at helper.JavaHelper.main(JavaHelper.java:138)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
I have those jars:
Looks like it should work to me (I have also tried with newer poi libs - same error).
Any ideas ?
A quick peek at Grepcode tells that the missing method is supported in v1.1
of ooxml-schemas
. Also the v1.0
doesn't seem to contain such a method (it only contains a getTrArray()
method).
So you may want to use ooxml-schemas-1.1.jar
instead of ooxml-schemas-1.0.jar
.
Here's the maven dependency of the version you should use at the very least:
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>ooxml-schemas</artifactId>
<version>1.1</version>
</dependency>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With