Get Excel SheetNames using POI jar

北慕城南 提交于 2019-12-07 04:56:34

问题


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


回答1:


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 = WorbookFactory.create(myFile);

List<String> sheetNames = new ArrayList<String>();
for (int i=0; i<wb.getNumberOfSheets(); i++) {
    sheetNames.add( wb.getSheetName(i) );
}


来源:https://stackoverflow.com/questions/12600883/get-excel-sheetnames-using-poi-jar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!