Java查询Excel模版时出现org.apache.poi.poifs.filesystem.OfficeXmlFileException异常


org.apache.poi.poifs.filesystem.OfficeXmlFileException: The supplied data appears to be in the Office 2007+ XML. You are calling the part of POI that deals with OLE2 Office Documents. You need to call a different part of POI to process this data (eg XSSF instead of HSSF)

该错误意思是说,文件中的数据是用Office2007+XML保存的,而现在却调用OLE2 Office文档处理,应该使用POI不同的部分来处理这些数据,比如使用XSSF来代替HSSF。

只需要导入poi的包即可!!!

1、百度输入 mvn repository,找到第一个网址打开:https://mvnrepository.com/    在输入框输入:poi

2、选择一个版本,凭我的经验,不要选择beta版本,也不要选择最新的按本。

3、点进去,copy如下内容,复制到自己pom.xml。更新一下,即可解决

<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi</artifactId>
    <version>3.13</version>
</dependency>

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM