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.
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