我使用 windows 7 home basic 64-bit 和 microsoft excel starter 2010,我想读取一个 excel 文件,但是当我调试我的代码时,我遇到了这个错误:The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.
我的代码如下:
protected void Page_Load(object sender, EventArgs e)
{
GridView1.DataSource=getirExcel();
GridView1.DataBind();
}
DataTable getirExcel()
{
string dosya_adres = @"C:\Users\Erdi\Downloads\DBE_BAKIM_FORMU.xlsx";
OleDbConnection baglanti = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + dosya_adres + ";Extended Properties=Excel 12.0");
baglanti.Open();
string query = "select * from [Sheet1$A1:D20]";
OleDbDataAdapter oAdp = new OleDbDataAdapter(query, baglanti);
DataTable dt = new DataTable();
oAdp.Fill(dt);
return dt;
}
我已经尝试过Microsoft.JET.OLEDB.4.0
,但根据论坛,它不适用于 64 位。你知道任何替代供应商吗?
提前致谢..