我的本地PC安装了Windows7 64位和Microsoft Excel 2010 但我的大多数客户的PC都是XP Professional Service Pack 3和Excel 2003
我为Excel文件的导入数据获取了此连接字符串
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyExcel.xls;Extended Properties="Excel 8.0;HDR=Yes;IMEX=1";
但这会引发错误,说
The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine.
我希望我的应用程序可以在x86和x64架构上读取Excel文件。 如何在不在PC上安装额外的Excel驱动程序的情况下以编程方式处理它?</ p>
我正在考虑使用不同的连接字符串来导入基于CPU架构的Excel文件。
有没有更好的主意?
答案 0 :(得分:2)
确保在开发系统上安装了支持x86和x64的Jet驱动程序。
Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine
答案 1 :(得分:0)
这是因为Visual Studio中的编译配置与系统上安装的ACE版本不匹配。 (Ref: How to read or write excel file using ACE OLEDB data provider?。)
您可以通过确保两者相同来解决它。如果安装了64位ACE,则使用x64位编译应用程序或使用32位ACE。