简体   繁体   English

C#XLS和XLSX文件导入

[英]c# xls and xlsx file import

I want to load xls and xlsx file in c#. 我想在C#中加载xls和xlsx文件。 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." 对于xls,我使用的是:Provider = Microsoft.Jet.OLEDB.4.0; Data Source =;扩展属性= \\“ Excel 8.0; HDR = YES \\对于xlsx:Provider = Microsoft.Ace.OLEDB.12.0; Data Source =;扩展属性= \\“ Excel 12.0; HDR = YES \\\\”一旦项目平台目标是任何Cpu,我都可以毫无问题地上传xlsx文件,但是当我上传xls文件时,出现以下错误:“'Microsoft.Jet.OLEDB.4.0'提供程序未在本地计算机上注册。”

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." 而且,如果我将Platform Target更改为x86,则可以毫无问题地上传xls文件,但是这次xlsx文件给出了此错误:“'Microsoft.Ace.OLEDB.12.0'提供程序未在本地计算机上注册。”

How can I upload but file formats without error? 如何上传但文件格式没有错误?

Thanks 谢谢

两种文件都应使用ACE.OleDB。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM