Bug 45430

Summary: XSSFName.getSheetName() returns the wrong value
Product: POI Reporter: Matthew <matthew.knl>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Attachments: Test Data
Macro-enabled workbook package structure
My patch to solve "save macro-enabled workbook" issue, temporary solution

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.