我目前正在从excel导入到c#,但这是第一次这样做,我以为我在解决了一个数字后有连接工作的其他问题,但我现在正在接受上述错误。当试图将数据拉入C#时发现“找不到可安装的ISAM”错误
该代码构建得非常好,我找不到任何其他问题,任何人有任何想法?
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);
}
}
}
}
}
}
哪条线做这个突破?它是否读取任何行,并通过XLS文件中断部分? – Mangist
嗨,它断Connection.Open();并且在此之前不读取任何行。 –
将连接字符串的提供者部分更改为Provider = Microsoft.ACE.OLEDB.12.0; – Mangist