//打开一个文档
string path = System.Windows.Forms.Application.StartupPath;
path = path.Replace(@"\", @"\\") + @"\\x86\\TimeAttendance.xls";
HSSFWorkbook workbook;
using (FileStream stream = File.OpenRead(path))
{
workbook = new HSSFWorkbook(stream);
}
int SheetCount= workbook.NumberOfSheets;//获取表的数量
string[] SheetName = new string[SheetCount];//保存表的名称
for (int i = 0; i < SheetCount; i++)
SheetName[i] = workbook.GetSheetName(i);
foreach(string i in SheetName)//测试读取状态
richTextBox1.Text +=i;
workbook.Clear();
c# NPOI读取excel的sheet名称
最新推荐文章于 2024-07-07 08:00:00 发布