Dear POI users / developers,
I just came across the following case:
I have an Excel file with three sheets called AAA, BBB, CCC. On each of them
there is a name defined: AA on AAA, BB on BBB, CC on CCC. If I'm now
removing sheet BBB, the behaviour for a HSSF workbook is different than for
a XSSF workbook. The following is what I observe:
- HSSF: Sheets AAA and CCC remain (which is ok), but left are only names AA
and BB. This is strange. I would understand if BB would be missing but CC
should definitely still be around I guess. Also, if you open the file with
an older Excel version (< 2007) you are confronted with a dialog saying that
the file has been repaired. Excel 2007+ seems to do that behind the scenes.
- XSSF: Sheets AAA and CCC remain (again, this is ok), and so do the names
AA and CC. This behaviour seems ok to me.
Please find a snippet of code that can be used to reproduce this behaviour:
Workbook wb = WorkbookFactory.create(new
FileInputStream("C:/Users/mstuder/Documents/Test.xls"));
wb.removeSheetAt(wb.getSheetIndex("BBB"));
wb.write(new FileOutputStream("C:/Users/mstuder/Documents/Test2.xls"));
Also, please find attached the two corresponding Excel files (xls and xlsx).
Regards,
Martin
Test.xls
Description: MS-Excel spreadsheet
Test.xlsx
Description: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
--------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
