You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2010/03/16 17:38:41 UTC
DO NOT REPLY [Bug 48923] New: Method Name.getSheetIndex() fails to
return valid sheet index
https://issues.apache.org/bugzilla/show_bug.cgi?id=48923
Summary: Method Name.getSheetIndex() fails to return valid
sheet index
Product: POI
Version: 3.6
Platform: PC
OS/Version: Windows 2000
Status: NEW
Severity: normal
Priority: P2
Component: XSSF
AssignedTo: dev@poi.apache.org
ReportedBy: wholder@nglm.com
Created an attachment (id=25136)
--> (https://issues.apache.org/bugzilla/attachment.cgi?id=25136)
Test file for example code
In this example:
InputStream inp = new FileInputStream("Book.xlsx"); // or .xls
Workbook wb = WorkbookFactory.create(inp);
int names = wb.getNumberOfNames() ;
if (names > 0) {
for (int ii = 0; ii < names; ii++) {
Name name = wb.getNameAt(ii);
String sName = name.getSheetName();
//int nameIdx = name.getSheetIndex(); // Hmm... doesn't work
int nameIdx = wb.getSheetIndex(sName); // Alternate method
}
}
the commented out line always returns -1, even when the named cell, or range is
on a specific sheet. The following line shows a workaround. Note: this
problem
also happens for .xls files.
Wayne
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
DO NOT REPLY [Bug 48923] Method Name.getSheetIndex() fails to return
valid sheet index
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48923
Nick Burch <ni...@alfresco.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |INVALID
--- Comment #1 from Nick Burch <ni...@alfresco.com> 2010-05-26 10:52:07 EDT ---
You're using the wrong method there.
getSheetIndex will tell you which Sheet a named range is DEFINED FOR, or -1 if
it applies to the whole of the workbook (see the javadocs for details). Your
named ranges apply to the whole of the workbook, which is why you get -1
You probably want name.getSheetName(), which gives you the sheet it references,
not the sheet it's defined on
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org