zoukankan      html  css  js  c++  java
  • C#读取Excel2007的文件

    以读取access数据集的方式读取    

    For excel 2007:

        private DataSet GetExcelData(string str)
        {
            string strCon = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + str + ";Extended Properties=\"Excel 12.0;HDR=YES\"";
            OleDbConnection myConn = new OleDbConnection(strCon);
            string strCom = " SELECT * FROM [Sheet1$]";
            myConn.Open();
            OleDbDataAdapter myCommand = new OleDbDataAdapter(strCom, myConn);
            DataSet myDataSet = new DataSet();
            myCommand.Fill(myDataSet, "[Sheet1$]");
            myConn.Close();
            return myDataSet;
        }

    For excel2003:

    连接字符串改为:

    string strCon = " Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source ="+str+";Extended Properties=Excel 8.0";

  • 相关阅读:
    U盘支持启动windows和Linux
    emacs安装
    npm 安装指定的第三方包
    npm安装第三方包
    npm 安装淘宝镜像
    ssm 环境搭建
    gitBook安装简介
    git 博客搭建
    git 多人开发
    git ssh提交
  • 原文地址:https://www.cnblogs.com/catvi/p/1952967.html
Copyright © 2011-2022 走看看