zoukankan      html  css  js  c++  java
  • 获取execl中所有的sheet名字

            private static List<string> GetExcelSheetNames(string filePath)
            {
                List<string> names = new List<string>();
                Microsoft.Office.Interop.Excel.Application excelApp = null;
                object missing = System.Reflection.Missing.Value;
                try
                {
                    excelApp = new Microsoft.Office.Interop.Excel.Application();
                    Microsoft.Office.Interop.Excel.Workbooks wbs = excelApp.Workbooks;
                    Microsoft.Office.Interop.Excel.Workbook wb = wbs.Open(filePath, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                    Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                    Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                    int count = wb.Worksheets.Count;
                    for (int i = 1; i <= count; i++)
                        names.Add(((Microsoft.Office.Interop.Excel.Worksheet)wb.Worksheets[i]).Name);
                    wb.Close(missing, missing, missing);
                    wb = null;
                    excelApp.Quit();
                }
                catch
                {
                    excelApp.Quit();
                }
                return names;
            }

  • 相关阅读:
    AT5200 [AGC038C] LCMs 莫比乌斯反演
    P5445 [APIO2019]路灯 树套树
    CF617E XOR and Favorite Number 莫队
    P5404 [CTS2019]重复 KMP自动机
    P4364 [九省联考2018]IIIDX 线段树上二分
    P3749 [六省联考2017]寿司餐厅 最大权闭合子图
    CF906E Reverses PAM+border
    AGC 补题记录
    做题记录
    题解 loj #3524. 「IOI2021」钥匙
  • 原文地址:https://www.cnblogs.com/xiguanjiandan/p/3365495.html
Copyright © 2011-2022 走看看