C#导入excel时报错:The 'Microsoft.Ace.OleDb.12.0' provider is not registered on the local machine

Asp.net 发布到IIS 上,做导入excel功能时报标题所写的错误。在网上找了许多方法,都未能解决问题,现问题得已解决,在此小结下,如有遇到同样问题,方便参考~

解决方法1:下载AccessDatabaseEngine(http://www.microsoft.com/zh-cn/download/details.aspx?id=23734)

支持的操作系统

Windows Server 2003 Service Pack 1, Windows Vista, Windows XP Service Pack 2

解决方法2:下载AccessDatabaseEngine(http://www.microsoft.com/zh-cn/download/details.aspx?id=13255)(这个兼容上面所说的,在此都列举出来哈~)

支持的操作系统

Windows 7, Windows Server 2003, Windows Server 2003 Service Pack 1, Windows Server 2003 Service Pack 2, Windows Server 2008 R2, Windows Server 2008 Service Pack 2, Windows Vista Service Pack 1, Windows XP Service Pack 2

在 Windows XP Service Pack 3 上只能使用 32 位 Access 数据库引擎

使用此下载:(参考微软Download Center

1.如果您是应用程序用户,请查阅应用程序文档以获得有关如何使用相应驱动程序的详细信息。

2.如果您是使用 OLEDB 的应用程序开发人员,请将 ConnectionString 属性的 Provider 参数设置为“Microsoft.ACE.OLEDB.12.0”

◦如果要连接到 Microsoft Office Excel 数据,请将“Excel 14.0”添加到 OLEDB 连接字符串的扩展属性中。

3.如果您是使用 ODBC 连接到 Microsoft Office Access 数据的应用程序开发人员,请将连接字符串设置为“Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=path to mdb/accdb file”

4.如果您是使用 ODBC 连接到 Microsoft Office Excel 数据的应用程序开发人员,请将连接字符串设置为“Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=path to xls/xlsx/xlsm/xlsb file

FYI