64位win Server 2003 ,读取excel错误解决方案.
使用连接字符串"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\d1.xls;Extended Properties=Excel 8.0;" 将会出现 System.InvalidOperationException: 未在本地计算机上注册“Microsoft.Jet.OLEDB.4.0”提供程序。
解决方案:
1.如果Jet引擎正常(打开"ODBC",转到“驱动程序”选项卡,有没有JET引擎),通过执行命令 cscript C:\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1 将64位的IIS转为32位方式运行,再用.Net Framework注册IIS,在IIS Web服务扩展中,激活ASP.NET v2.0.50727 (32bit),重启IIS。
FROM:
Enable 32-bit Server Applications on 64-bit Machines ASP.NET applications that use TX Text Control .NET Server must be compiled for 32-bit platforms (see this article). IIS must be configured to execute these 32-bit applications. Generally, all applications will be executed in 64-bit mode.
a). Enable IIS's 32-bit support Open a command prompt and type in the following command: cscript %SYSTEMDRIVE%\inetpub\adminscripts\adsutil.vbs SET W3SVC/AppPools/Enable32bitAppOnWin64 1 This command enables the 32-bit mode in IIS. b). Install the IIS 32-bit extensions Open a command prompt and type the following command: %SYSTEMROOT%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i This command installs the 32-bit web extensions for .NET Framework 2.0.
c). Activate .NET Framework 2.0 32-bit in IIS In the IIS-Manager, select the 'ASP.NET v2.0.50727 (32bit)' in the 'Web Service Extensions' panel and check 'allow' to activate it.
d). Restart the IIS by opening a command prompt: iisrestart
总的思路就是先允许IIS支持32位程序,然后再用.Net Framework注册IIS。
2.换二进制读取方式,可用第三方控件Aspose.cells.dll,这个控件不是免费的,我这里有个破解版。
Aspose.cells.dll下载
示例源码下载