Bug 49874 - Problems with names when removing a sheet from an HSSF workbook
Summary: Problems with names when removing a sheet from an HSSF workbook
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.7-dev
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2010-09-03 02:51 UTC by Martin Studer
Modified: 2010-12-23 20:19 UTC (History)
0 users

Zip file with the mentioned workbooks (Test.xls and Test.xlsx) (9.33 KB, application/zip)
2010-09-03 02:51 UTC, Martin Studer

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Studer 2010-09-03 02:51:29 UTC
Created attachment 25979 [details]
Zip file with the mentioned workbooks (Test.xls and Test.xlsx)

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 version of Excel (< 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 the problem:

Workbook wb = WorkbookFactory.create(new FileInputStream("C:/Users/mstuder/Documents/Test.xls"));
wb.write(new FileOutputStream("C:/Users/mstuder/Documents/Test2.xls"));

Also, please find attached the two corresponding Excel files (*.xls and *.xlsx).

OS: Windows 7
POI: 3.7-beta2
Java: 1.6.0_20 64-bit
Comment 1 awm 2010-12-23 20:19:00 UTC
As of last night's trunk AA, BB, and CC all appear in xlsx version after BBB is deleted.  I didn't try the OLE2.

I think leaving the BB named range is the proper outcome.