var excelConnectionString = ConfigurationSettings.GetExcelConnection(fileLocation);
var dataTable = new DataTable();
using (var excelConnection = new OleDbConnection(excelConnectionString))
{
excelConnection.Open();
var dataAdapter = new OleDbDataAdapter("SELECT * FROM [Users$]", excelConnection);
dataAdapter.Fill(dataTable);
excelConnection.Close();
}
Console.WriteLine("OpenExcelFile: File successfully opened:" + fileLocation);
return dataTable;
2 回答
通过Office 365程序从本地安装的Office 13升级到Office 16后,我发生了这种情况 . 我得到了这个例外:'Microsoft.ACE.OLEDB.12.0'提供程序未在本地计算机上注册 .
我无法通过Office 365安装过程找到安装驱动程序的方法 .
我不得不安装https://www.microsoft.com/en-us/download/details.aspx?id=13255 - x64版本没有解决问题,不得不使用32位版本 .
我在App.config中的连接字符串
使用它的代码:
这对我有用: