On Tue, 15 Feb 2011, Leigh wrote:
The documentation says HSSFWorkbook.getSheetIndex(sheetName) returns -1 when the given sheet name does not exist. But for some reason its returning "0" when the supplied name is "Sheet1" AND the workbook is empty. Strangely, it _only_ seems to happen when the name is "Sheet1".

When a new HSSFWorkbook is created, InternalWorkbook creates a bunch of records required to be a valid empty new file. One of those is a single BoundSheetRecord, which is what you're picking up.

I'd be tempted to add an extra check into the HSSFWorkbook level, where it won't drop down to the records when no sheets exist, which'd avoid this confusion. Hopefully other POI developers can chime in on the sanity of that...

Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to