Apache POI XmlException for theme

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


阿帕奇波伊 版本: 4.0.1


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


任何想法如何解决这种问题或库都可以使用。谢谢。


慕尼黑5688855
浏览 123回答 1
1回答

largeQ

阿帕奇POI不支持以严格OOXML格式保存的xlsx文件(使用&nbsp;http://purl.oclc.org/ooxml/drawingml&nbsp;命名空间)。尝试使用标准(过渡)OOXML 格式保存文件。如果您需要自己转换文件,https://github.com/pjfanning/ooxml-strict-converter&nbsp;可能会有所帮助。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java