Apache POI - Invalid part to process data

倖福魔咒の 提交于 2019-12-04 18:54:44

To open an xlsx (Office Open XML) file, you should use XSSFWorkbook instead of HSSFWorkbook, which is used for xls (Excel 97-2003) files.

If you are using POI < 3.5, you need to upgrade to at least version 3.5, in order to be able to read xlsx files. Here's a guide for doing the conversion, but essentially, you'd need to load the file using WorkbookFactory which takes care of the creation of either an XSSFWorkbook or HSSFWorkbook for you:

Workbook workbook = WorkbookFactory.create(new File("file.xlsx"))

Make sure the excel sheet is not corrupt, by opening it. If you seen any error, save the file as MS Excel 97-2003 Worksheet.
Also make sure you have specified the filename as "**.xls"

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!