Excel file created with apache poi (Java) can't be opened on Windows
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/