In a Java method, I am using an Apache POI Sheet (from XSSFWorkbook
). I can read the sheet name using getSheetName()
method. But is there any way to find the sheet position in the workbook? I don't see any methods like getSheetIndex()
in the Sheet interface.
Asked
Active
Viewed 1.3k times
6
1 Answers
22
Not in Sheet
interface but Workbook
has one method to do that :
Workbook.getSheetIndex(String name);
-
Thanks, I noticed that but was looking for something inside Sheet :-) else I have to call the parent workbook and then pass sheet name to it. Not very straight forward. But I guess no other way then. – Saikat Mar 18 '17 at 15:58
-
@takias There's no need! Just use [Sheet.getWorkbook](https://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/Sheet.html#getWorkbook())! – Gagravarr Mar 18 '17 at 19:51
-
6It will look like `Sheet.getWorkbook.getSheetIndex(sheet.getSheetName())` – Saikat Mar 19 '17 at 08:22