遭遇 读不出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

原文地址:https://www.cnblogs.com/freeliver54/p/1846069.html