在 c# 中读取 excel 文件时,'microsoft.ace.oledb.12.0' 提供程序未在本地计算机上注册

the 'microsoft.ace.oledb.12.0' provider is not registered on the local machine while reading a excel file in c#

我正在读取一个 excel 文件,我想访问它的内容。 我正在使用此连接字符串:

connectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0}; Extended Properties=Excel 12.0;", Server.MapPath(fileName));

但是我看到这个错误:

The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.

我的服务器是 运行 64 位操作系统。 我在上面安装了Microsoft Office Professional Plus 2010(32-bit)和Microsoft Access database engine 2010

问题是什么?

原因是 ACE.OLEDB.12.0 在 64 位操作系统中不工作。

你可以参考这个forum as well. You have to download the patch from here

如果可以解决您遇到的问题,请查看以下链接:

http://www.mikesdotnetting.com/article/280/solved-the-microsoft-ace-oledb-12-0-provider-is-not-registered-on-the-local-mac

http://www.codeproject.com/Tips/417397/OLEDB-Provider-is-Not-Registered-on-the-Local-Mach

https://social.msdn.microsoft.com/Forums/en-US/f11b2df9-fd0a-4528-987f-f95dfdccee0a/microsoftaceoledb120-provider-is-not-registered-on-the-local-machine-error?forum=adodotnetdataproviders

最后一个建议从 - http://www.microsoft.com/en-us/download/details.aspx?id=13255

下载补丁