Reputation: 1139
I need to delete first sheet from the workbook (num of sheets > 1).
This is my code:
inputStreamExcel = new FileInputStream(path);
wrkbook = new XSSFWorkbook(inputStreamExcel );
wrkbook .removeSheetAt(0);
outputStreamExcel = new FileOutputStream(path);
wrkbook.write(outputStreamExcel );
outputStreamExcel .flush();
outputStreamExcel .close();
I am not getting any exceptions. But when I try to open the excel file I get an error:
excel found unreadable content...
Upvotes: 1
Views: 971
Reputation: 13882
This error occurs when your excel has not been saved properly,
probably you might want to check that while saving, the current selected/active cell
is not pointing to a null row, or the active sheet
is not null
Upvotes: 1
Reputation: 903
Try setting the active sheet again after you remove the first sheet:
...
wrkbook.removeSheetAt(0);
wrkbook.setActiveSheet(0);
...
this should solve the problem.
Upvotes: 1