Excel file created with apache poi (Java) can't be opened on Windows

ぃ、小莉子 提交于 2019-12-05 18:11:01

As Axel mentioned, the problem was the file extension.

I can open the files created this way in Ubuntu (Both 14.04 and 16.04), but not in Windows (7, 8 and 10).

The solution is to use the .xls extension and NOT .xlsx, that way I can open and use the files in any OS.

HSSF is the Office 97 *.xls format. (It stands for Horrible Spreadsheet Format.)

} catch (FileNotFoundException e) {
    workbook = new HSSFWorkbook();
}

When you did that, you chose the *.xls format. You need to use XSSFWorkbook if you want *.xlsx format.

https://poi.apache.org/components/spreadsheet/quick-guide.html#NewWorkbook

https://poi.apache.org/components/spreadsheet/

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