首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用于主题的Apache POI XmlException (http://purl.oclc.org/ooxml/drawingml)

用于主题的Apache POI XmlException (http://purl.oclc.org/ooxml/drawingml)
EN

Stack Overflow用户
提问于 2019-04-05 21:34:05
回答 1查看 645关注 0票数 0

目前,我正在使用Apache POI读取excel文件(.xlsx),但在传递数据流时,在XSSFWorkbook实例化过程中遇到异常。下面是遇到的异常。

Apache Poi版本: 4.0.1

代码语言:javascript
复制
Exception in thread "main" org.apache.poi.ooxml.POIXMLException: error: The document is not a theme@http://schemas.openxmlformats.org/drawingml/2006/main: document element namespace mismatch expected "http://schemas.openxmlformats.org/drawingml/2006/main" got "http://purl.oclc.org/ooxml/drawingml/main"
    at org.apache.poi.ooxml.POIXMLFactory.createDocumentPart(POIXMLFactory.java:66)
    at org.apache.poi.ooxml.POIXMLDocumentPart.read(POIXMLDocumentPart.java:657)
    at org.apache.poi.ooxml.POIXMLDocument.load(POIXMLDocument.java:180)
    at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:286)
    at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:307)
    at com.wl.dni.excel.parser.Test.main(Test.java:47)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:56)
    at org.apache.poi.ooxml.POIXMLFactory.createDocumentPart(POIXMLFactory.java:63)
    ... 5 more
Caused by: java.io.IOException: error: The document is not a theme@http://schemas.openxmlformats.org/drawingml/2006/main: document element namespace mismatch expected "http://schemas.openxmlformats.org/drawingml/2006/main" got "http://purl.oclc.org/ooxml/drawingml/main"
    at org.apache.poi.xssf.model.ThemesTable.<init>(ThemesTable.java:88)
    ... 11 more
Caused by: org.apache.xmlbeans.XmlException: error: The document is not a theme@http://schemas.openxmlformats.org/drawingml/2006/main: document element namespace mismatch expected "http://schemas.openxmlformats.org/drawingml/2006/main" got "http://purl.oclc.org/ooxml/drawingml/main"
    at org.apache.xmlbeans.impl.store.Locale.verifyDocumentType(Locale.java:454)
    at org.apache.xmlbeans.impl.store.Locale.autoTypeDocument(Locale.java:359)
    at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1275)
    at org.apache.xmlbeans.impl.store.Locale.parseToXmlObject(Locale.java:1259)
    at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.parse(SchemaTypeLoaderBase.java:345)
    at org.openxmlformats.schemas.drawingml.x2006.main.ThemeDocument$Factory.parse(Unknown Source)
    at org.apache.poi.xssf.model.ThemesTable.<init>(ThemesTable.java:86)
    ... 11 more

可以使用任何想法来修复这类问题或库。谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-04-06 00:20:16

Apache POI不支持以严格的OOXML格式(使用http://purl.oclc.org/ooxml/drawingml名称空间)保存的xlsx文件。

尝试使用标准(过渡) OOXML格式保存文件。

如果您需要自己转换文件,https://github.com/pjfanning/ooxml-strict-converter可能会有所帮助。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55536616

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档