【发布时间】:2014-11-10 23:16:37
【问题描述】:
我正在尝试编写一段代码来读取 docx 文件,但由于某些奇怪的原因它失败了。
在这一行失败:
XWPFDocument document = new XWPFDocument(new FileInputStream(filepath));
堆栈跟踪:
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)
我有那些罐子:
- dom4j-1.6.1.jar
- xmlbeans-2.3.0.jar
- poi-3.9-20121203.jar
- poi-scratchpad-3.9-20121203.jar
- poi-ooxml-3.9-20121203.jar
- ooxml-schemas-1.0.jar
看起来它应该对我有用(我也尝试过使用较新的 poi 库 - 同样的错误)。
有什么想法吗?
【问题讨论】:
标签: java apache-poi