![](/img/trans.png)
[英]“Could not find installable ISAM” error when trying to parse an excel spreadsheet
[英]“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' ";
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.