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

  • 相关阅读:
    超级有用的15个mysqlbinlog命令
    表迁移工具的选型-复制ibd的方法-传输表空间
    误删mysql表物理文件的解决方法(不涉及恢复数据)
    美团SQL优化工具SQLAdvisor
    Linux网络状态工具ss命令使用详解
    MySQL应用架构优化-实时数据处理
    运维利器万能的 strace
    ngrep命令用法
    [Linux|DBA]运维三十六计
    sysbench使用
  • 原文地址:https://www.cnblogs.com/xiguanjiandan/p/3365495.html
Copyright © 2011-2022 走看看