Bug 45430 - XSSFName.getSheetName() returns the wrong value
Summary: XSSFName.getSheetName() returns the wrong value
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: unspecified
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
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.