Problems reading in an Excel file in C#

后端 未结 4 2114
不思量自难忘°
不思量自难忘° 2021-01-23 07:57

I\'m reading an Excel file with OLDB Connection using this code

        var connectionString = string.Format(\"Provider=Microsoft.Jet.OLEDB.4.0; data source={0};         


        
4条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-23 08:32

    I had this exact problem and solve it with using IMEX setting. In case others are wondering how to include the IMEX, here is what I have on my connection string

    string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties='Excel 8.0;IMEX=1';Data Source={0};";
    connectionString = string.Format(connectionString, excelWorkbookPath);
    

提交回复
热议问题