试图将数据拉入C#时发现“无法find可安装的ISAM”错误

我目前正在从excel导入到C#,但这是第一次这样做,我以为我有解决了一些其他问题后,连接工作,但我现在正在接受上述错误。

代码的构build非常好,我找不到任何其他问题,任何人有任何想法?

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来得到这个工作:

 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' ";