I have created a Workbook/Excel in .xlsx format with Java using Apache POI API successfully. My code is as below that is created a file named "RiponAlWasim.xlsx" in D drive:
Workbook wb = new XSSFWorkbook();
FileOutputStream fileOut = new FileOutputStream("D:\\RiponAlWasim.xlsx");
wb.write(fileOut);
fileOut.close();
wb.close();
When I tried to open "RiponAlWasim.xlsx" it was shown the file is corrupted. What's the wrong?
fileOut.flush()beforeclose(). Also, you might need to add at least one worksheet to the workbook, And you should close the workbook before writing