poi文件导入报错:The supplied data appears to be in the Office 2007+ XML

错误信息为:

Exception in thread "main" 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)

原因:HSSFWorkbook只能处理扩展名为.xls的文件,也就是excel2007以前的文件。

 

解决办法:可以将.xlsx文件另存为.xls文件再进行处理(不是直接改扩展名)。

当然也可以使用XSSF 来接收处理文件

你可能感兴趣的:(error)