为了账号安全,请及时绑定邮箱和手机立即绑定

Apache POI XmlException for theme

Apache POI XmlException for theme

慕尼黑5688855 2022-09-22 16:12:57
目前,我正在使用Apache POI来读取excel文件(.xlsx),但在实例化传递数据流时遇到异常。以下是遇到的例外情况。XSSFWorkbook阿帕奇波伊 版本: 4.0.1Exception 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 moreCaused 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任何想法如何解决这种问题或库都可以使用。谢谢。
查看完整描述

1 回答

?
largeQ

TA贡献2039条经验 获得超7个赞

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

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

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


查看完整回答
反对 回复 2022-09-22
  • 1 回答
  • 0 关注
  • 119 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信