c# NPOI读取excel的sheet名称

            //打开一个文档
            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();

你可能感兴趣的:(NPOI,读取excel的sheet名称)