zoukankan      html  css  js  c++  java
  • 遭遇 读不出excel中的文本列的数字值 及 找不到可安装的ISAM

    最后 查找和修改Excel连接字串 解决

        #region 读Excel
        private void fnReadExcel(string  strFileName ,string strSheetName,string strColumnName ,out DataSet dsData)
        {
            //strColumnName = " * ";
            string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source =" + strFileName + ";Extended Properties =  'Excel 8.0;HDR=Yes;IMEX=1;'";
            OleDbConnection oleConnection = new OleDbConnection(strConnection);
            try
            {
                oleConnection.Open();
                string strCommondText = "SELECT " + strColumnName + " FROM [" + strSheetName + "]";
                DataSet dsRead = new DataSet();
                OleDbDataAdapter oleAdper = new OleDbDataAdapter(strCommondText, oleConnection);
                oleAdper.Fill(dsRead);
                dsData = dsRead;
            }
            catch (System.Exception ex)
            {
                //throw new ApplicationException("读取数据源文件时出错");
                dsData = null;
            }
            finally
            {
                oleConnection.Close();
            }
        }
        #endregion

  • 相关阅读:
    1007 素数对猜想 (20 分)
    1005 继续(3n+1)猜想 (25 分)
    1002 写出这个数 (20 分)
    1001 害死人不偿命的(3n+1)猜想 (15 分)
    mysql常用操作
    mysql乱码问题
    mysql忘记root密码
    linux开机启动
    fedora 调整屏幕亮度
    Access denied for user 'root'@'localhost' (using password:YES) 解决方案
  • 原文地址:https://www.cnblogs.com/freeliver54/p/1846069.html
Copyright © 2011-2022 走看看