Bug 45430 - XSSFName.getSheetName() returns the wrong value
XSSFName.getSheetName() returns the wrong value
Status: RESOLVED FIXED
Product: POI
Classification: Unclassified
Component: HSSF
unspecified
PC Windows XP
: P2 normal (vote)
: ---
Assigned To: POI Developers List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2008-07-18 02:28 UTC by Matthew
Modified: 2008-07-20 18:57 UTC (History)
0 users



Attachments
Test Data (7.74 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2008-07-18 02:28 UTC, Matthew
Details
Macro-enabled workbook package structure (18.32 KB, image/jpeg)
2008-07-20 18:49 UTC, Matthew
Details
My patch to solve "save macro-enabled workbook" issue, temporary solution (24.49 KB, application/octet-stream)
2008-07-20 18:50 UTC, Matthew
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew 2008-07-18 02:28:14 UTC
Created attachment 22279 [details]
Test Data

I am using POI 3.5 Beta 1.
I write following code to list all the Named Range in the Excel Workbook.

Workbook wb = new XSSFWorkbook(xlsx_path);
for(int j=0; j<wb.getNumberOfNames(); j++){
	Name name = wb.getNameAt(j);				
	String reference = name.getReference();
	String sheetName = name.getSheetName();
	System.out.println("reference: " + reference);
	System.out.println("sheetName: " + sheetName);
}

I found that the .getSheetName() method return the wrong value, it always return sheet one name, which doesn't match with .getReference() (the sheet name part).

I have uploaded a sample .xlsx file, which contains three worksheets, each worksheet $A$1 has defined a named range. You can run above codes to check the result.

Expected Result:
reference: SheetA!$A$1
sheetName: SheetA
reference: SheetB!$A$1
sheetName: SheetB
reference: SheetC!$A$1
sheetName: SheetC

Actual Result:
reference: SheetA!$A$1
sheetName: SheetA
reference: SheetB!$A$1
sheetName: SheetA
reference: SheetC!$A$1
sheetName: SheetA
Comment 1 Nick Burch 2008-07-18 10:37:49 UTC
Fixed in svn - was an issue when no localSheetId was given
Comment 2 Matthew 2008-07-20 18:49:16 UTC
Created attachment 22287 [details]
Macro-enabled workbook package structure
Comment 3 Matthew 2008-07-20 18:50:31 UTC
Created attachment 22288 [details]
My patch to solve "save macro-enabled workbook" issue, temporary solution
Comment 4 Matthew 2008-07-20 18:57:08 UTC
(In reply to comment #2)
> Created an attachment (id=22287) [details]
> Macro-enabled workbook package structure
> 

Sorry, this attachment is should be referred to bug#45430.
Comment 5 Matthew 2008-07-20 18:57:29 UTC
(In reply to comment #3)
> Created an attachment (id=22288) [details]
> My patch to solve "save macro-enabled workbook" issue, temporary solution
> 

Sorry, this attachment is should be referred to bug#45430.