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>

本文来自博客园,作者:编程狸,转载请注明原文链接:https://www.cnblogs.com/ping-pong/p/9843911.html

原文地址:https://www.cnblogs.com/ping-pong/p/9843911.html