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

  • 相关阅读:
    整理:深度学习 vs 机器学习 vs 模式识别
    机器学习部分国内牛人
    图像去模糊
    删除流氓软件McAfee
    ceshi
    linux系统加快大文件的写入速度
    修改cmd的字体为Consolas字体
    gdb的可视化工具安装
    微服务编译、启动jar命令指定配置文件
    pycharm中安装可以贴图片的Markdown插件
  • 原文地址:https://www.cnblogs.com/xiguanjiandan/p/3365495.html
Copyright © 2011-2022 走看看