POI OLE2NotOfficeXmlFileException:The supplied data appears to be in the OLE2 Format问题解决
问题描述: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) Docu
文章共282字 · 阅读需要大约1分钟
一键AI生成摘要,助你高效阅读
问答
·
问题描述:
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)
问题分析:
1、读取Word文件时,使用了XWPFDocument读取doc文件。
解决办法:doc文件使用HWPFDocument读取,docx文件使用XWPFDocument读取。
2、读取Excel文件时,使用了XSSFWorkbook读取xls文件。
解决办法:xls文件使用HSSFWorkbook读取,xlsx文件使用XSSFWorkbook读取。
更多推荐
已为社区贡献35条内容
所有评论(0)