使用 POI jar 获取 Excel SheetNames [英] Get Excel SheetNames using POI jar

查看:40
本文介绍了使用 POI jar 获取 Excel SheetNames的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用 POI jar 的所有 Excel 工作表名称(所有包含数据的内容).像 jxl jar - getSheetNames()

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

推荐答案

你不会说出你想要它们的方式,所以我会猜测一个列表.您只需要遍历工作表索引,获取每个索引的名称.您的代码将类似于:

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) );
}

这篇关于使用 POI jar 获取 Excel SheetNames的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆