c#xls和xlsx文件导入 [英] c# xls and xlsx file import
问题描述
我想在c#中加载xls和xlsx文件。对于xls我正在使用:
Provider = Microsoft.Jet.OLEDB。 4 。 0 跨度>;
数据源=;扩展属性= \ Excel 8.0; HDR = YES \
对于xlsx:
Provider = Microsoft.Ace.OLEDB。 12 。 0 ;
数据源=;
扩展属性= \ Excel 12.0; HDR = YES \
一旦项目平台目标为Any Cpu我可以毫无问题地上传xlsx文件但是当我上传xls文件时出现以下错误:
'Microsoft.Jet.OLEDB.4.0'提供商不是在本地机器上注册。
如果我将平台目标更改为x86然后上传xls文件没有问题,但这次xlsx文件出现此错误:
'Microsoft.Ace.OLEDB.12.0'提供程序未在本地计算机上注册。
我怎么上传但是文件格式没有错误?
谢谢
使用相同的ACE.OleDB工作..
JET仅支持32位。
与ACE驱动程序的Xls:
Provider = Microsoft。 Ace 。 OLEDB 。 12 .0;
数据来源=;
扩展属性= \Excel 8 .0; HDR = YES \
带有ACE驱动程序的XLSX:
Provider = Microsoft。 Ace 。 OLEDB 。 12 跨度> 0.0;
数据来源=;
扩展属性= \Excel 12 .0; HDR = YES \
还可以为您的应用构建特定的x86。不要使用任何CPU。当使用Office 12.0 ACE驱动程序时,我在64位操作系统上遇到了问题。
您也可以尝试最新的驱动程序:
http://www.microsoft.com/en-us/download/ details.aspx?id = 13255 [ ^ ]
I want to load xls and xlsx file in c#. For xls I''m using:
Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=;Extended Properties=\"Excel 8.0;HDR=YES\
For xlsx :
Provider=Microsoft.Ace.OLEDB.12.0;
Data Source=;
Extended Properties=\"Excel 12.0;HDR=YES\
once the projects platform target was Any Cpu I can upload xlsx file without problem but when I upload xls file I got the following error:
"The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine."
And if I change the Platform Target to x86 then xls file is uploaded without problem but this time xlsx file is giving this error:
"The 'Microsoft.Ace.OLEDB.12.0' provider is not registered on the local machine."
How can I upload but file formats without error?
Thanks
Using the same ACE.OleDB works..
JET Supports only 32 bit.
Xls with ACE Driver:
Provider=Microsoft.Ace.OLEDB.12.0; Data Source=; Extended Properties=\"Excel 8.0;HDR=YES\"
XLSX with ACE Driver:
Provider=Microsoft.Ace.OLEDB.12.0; Data Source=; Extended Properties=\"Excel 12.0;HDR=YES\"
And also make build to Specific x86 for your app. Do not use Any CPU. I have faced issues on 64 bit OS when Office 12.0 ACE driver used.
You may also try latest driver:
http://www.microsoft.com/en-us/download/details.aspx?id=13255[^]
这篇关于c#xls和xlsx文件导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!