The supplied data appears to be in the OLE2 Format. You are calling the part of POI that deals with OOXML (Office Open XML) Documents. You need to call a different part of POI to process this data (eg HSSF instead of XSSF)

在做Excel导入功能时,发现导入的文件报错,代码中判断了文件类型:

// IO流读取文件
InputStream input = file.getInputStream();
//解析xls
HSSFWorkbook wb = new HSSFWorkbook(input);
//解析xlsx
XSSFWorkbook wbx = new XSSFWorkbook(input);

但是依旧报错:

org.apache.poi.openxml4j.exceptions.OLE2NotOfficeXmlFileException: The supplied data appears to be in the OLE2 Format. You are calling the part of POI that deals with OOXML (Office Open XML) Documents. You need to call a different part of POI to process this data (eg HSSF instead of XSSF)

网上查询也都是版本问题。

后来反复测试,发现xls导入没问题,但是将文件后缀直接改成xlsx导入就会报错。

将文件另存为xlsx后,再次导入,就不在报错了。

总结:

修改文件类型时最好使用另存为,避免出现版本问题。

The supplied data appears to be in the OLE2 Format.相关推荐

  1. The supplied data appears to be in the OLE2 Format. You are calling the part of POI that deals with

    The supplied data appears to be in the OLE2 Format. You are calling the part of POI that deals with  ...

  2. 使用poi导入Excel文件兼容性问题,The supplied data appears to be in the OLE2 Format.

    今天在处理Excel文件时候,发现对于以xls和xlsx为后缀的文件,用以下的代码处理时候抛 The supplied data appears to be in the OLE2 Format.异常 ...

  3. 【spring boot】【POI】错误:The supplied data appears to be in the Office 2007+ XML

    前言 spring boot 2.1.1.RELEASE poi 5.0.0 错误 Caused by: org.apache.poi.poifs.filesystem.OfficeXmlFileEx ...

  4. The supplied data appears to be in the Office 2007+ XML问题解决

    碰到了一个因为导入一个Excel文件的问题 The supplied data appears to be in the Office 2007+ XML 错误描述 org.apache.poi.po ...

  5. The supplied data appears to be in the Office 2007+ XML

    错误原文 The supplied data appears to be in the Office 2007+ XML. You are calling the part of POI that d ...

  6. 异常:The supplied data appears to be in the Office 2007+ XML

    我遇到这个异常时,是在处理excel时,根据字节数组流创建HSSFWorkbook对象时报的错,这个是excel兼容性的问题. 处理xls结尾的文件时,用HSSFWorkbook及其相关类型:而处理x ...

  7. 导入excel时报错The supplied data appears to be in the Office 2007+ XML.

    bug1: HSSFWorkbook:是操作Excel2003以前(包括2003)的版本,扩展名是.xls XSSFWorkbook:是操作Excel2007的版本,扩展名是.xlsx 另存文件改后缀 ...

  8. The supplied data appears to be in the Office 2007+ XML. You are calling the

    如果是xls,使用HSSFWorkbook:如果是xlsx,使用XSSFWorkbook

  9. ValueError: time data ‘2020,1 ,1‘ does not match format ‘%Y,%m,%d‘

    ValueError: time data '2020,1 ,1' does not match format '%Y,%m,%d' 数据存储的分隔符与对应的参数格式分隔符亦必须与其保持一致,否则就会 ...

最新文章

  1. yii2 后台权限验证获取用户身份_Yii2搭建后台并实现rbac权限控制完整实例教程...
  2. python的六大数据类型中可以改变的数据类型为_Python中数据类型转换
  3. ofstream写不进txt文件的奇怪问题
  4. 【干货】极简体验+免费真的万能嘛?北森Saas第一坑:免费
  5. zcmu1156: 新年彩灯Ⅰ
  6. Jquery 获取日期date()对象,jquerydate
  7. Mac(OS X)使用brew安装软件
  8. EdgeBERT:极限压缩,比ALBERT再轻13倍!树莓派上跑BERT的日子要来了?
  9. iscsi:IO操作流程(二)
  10. Atitit.数据索引 的种类以及原理实现机制 索引常用的存储结构
  11. 顺丰开放平台开发者接入指引
  12. 程序员必备的17个软件开发工具
  13. 2022年华数杯C题插层熔喷非织造材料的性能控制研究数学建模论文及程序
  14. c#字符串学习之祖玛游戏~
  15. 嵌入式操作系统课程作业之Write OS
  16. 重置Google云服务器密码
  17. (转)echarts 提示框tooltip被遮挡的解决办法
  18. 中职组“网络安全”数据包分析
  19. RPA未来发展趋势,Robot as a service是一个不错的方向吗?
  20. 用python计算图像面积_地图图像中屋顶面积的计算

热门文章

  1. 结构化思维-学习笔记
  2. 十大征兆表明是时候辞职了
  3. 华南理工大学计算机系就业率,21考研择校:华南理工大学就业率和薪酬情况统计!...
  4. 阿里云国际登录出现手机验证怎么办?
  5. 芯片设计IP核公司总结与分析
  6. 基于物联网技术的课程考试监考系统
  7. java布尔类型定义_Java如何正确定义布尔类型变量的命名
  8. 华硕笔记本快速启动项里面没有usb设备解决办法
  9. 多线程-静态代理-Lambda表达式
  10. aistarter助手程序未运行_使用APPinventor中的模拟器(及aistarter)