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: [email protected]
ReportedBy: [email protected]
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: [email protected]
For additional commands, e-mail: [email protected]