Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Excel SheetNames using POI jar

I need all Excel sheet Names (what r all contains the datas) using POI jar. Like jxl jar - getSheetNames()

like image 555
softmage99 Avatar asked Sep 26 '12 11:09

softmage99


Video Answer


1 Answers

You don't say how you want them, so I'll guess at a list. You just need to iterate over the sheet indicies, getting the name for each. Your code would be something like:

File myFile = new File("/path/to/excel.xls");
Workbook wb = WorkbookFactory.create(myFile);

List<String> sheetNames = new ArrayList<String>();
for (int i=0; i<wb.getNumberOfSheets(); i++) {
    sheetNames.add( wb.getSheetName(i) );
}
like image 161
Gagravarr Avatar answered Oct 01 '22 07:10

Gagravarr