"Cannot find installable ISAM" 尝试将数据拉入 C# 时出错

"Cannot find installable ISAM" error when trying to pull data into C#

我目前正在处理从 excel 到 c# 的导入,但这是第一次这样做,我以为我在解决了一些其他问题后可以正常连接,但我现在收到上述错误。

代码构建得非常好,我找不到任何其他问题,有人有什么想法吗?

using System;
using System.Collections.Generic;
using System.Data.OleDb;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test_excel
{
class Program
{
    static void Main(string[] args)
    {
        // @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path + ";Extended Properties='Excel 8.0;HDR=YES;IMEX=1;';"
        string con =
@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source='C:\Users\Joshua.cameron\Documents\BullenGrosvenorTest\EstatesITExportSpec.xlsx';Extended Properties='Excel 12.0 Xml;HDR=YES;IMEX=1;';";
// @"Extended Properties='Excel 12.0 Xml;HDR=YES;IMEX=1'";
        using (OleDbConnection connection = new OleDbConnection(con))
        {
            connection.Open();
            OleDbCommand command = new OleDbCommand("select * from [Rental Sheet$]", connection);
            using (OleDbDataReader dr = command.ExecuteReader())
            {
                while (dr.Read())
                {
                    var row1ColA = dr[0];
                    Console.WriteLine(row1ColA);
                }
            }
        }
    }
}

}

我将连接字符串修改为:

string con = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Joshua.cameron\Documents\BullenGrosvenorTest\EstatesITExportSpec.xlsx;Extended Properties='Excel 12.0 Xml;HDR=YES' ";