Bug 51889 - Name.getSheetIndex returns wrong value
Summary: Name.getSheetIndex returns wrong value
Status: RESOLVED INVALID
Alias: None
Product: POI
Classification: Unclassified
Component: XSSF (show other bugs)
Version: 3.8-dev
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-26 09:25 UTC by Martin Studer
Modified: 2012-02-28 17:29 UTC (History)
0 users



Attachments
Excel worksheet for bug reproduction (14.82 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2011-09-26 09:25 UTC, Martin Studer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Studer 2011-09-26 09:25:40 UTC
Created attachment 27592 [details]
Excel worksheet for bug reproduction

Name.getSheetIndex returns the wrong value. See the following example:

Workbook wb = WorkbookFactory.create(new FileInputStream("mtcars.xlsx"));
Name n = wb.getName("mtcars");
System.out.println(n.getSheetName());
System.out.println(n.getSheetIndex());

Sheet Name: mtcars
Sheet Index: -1

Corresponding workbook is attached.
Comment 1 Yegor Kozlov 2012-02-28 17:29:14 UTC
I don't see a bug here.

Name.getSheetName() and Name.getSheetIndex() have different meanings.


getSheetIndex() defines name scope. -1 means workbook-global, otherwise it is 0-based sheet index.

getSheetName() returns sheet name which this named range is referenced to. The name is 'mtcars!$A$1:$K$33' and this method returns mtcars.

Yegor