如何使用OPENXML将Excel数据读取到数据表? [英] How to read excel data to datatable using OPENXML?

查看:66
本文介绍了如何使用OPENXML将Excel数据读取到数据表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我想从 excel文件中读取数据,并希望将其存储在 datatable 。以前我使用的是 interop excel 。但是它多次给COM异常。所以我想切换到 OPENXML 。但我无法读取其中的xls文件。它显示损坏的数据异常。任何1都有示例代码来修复它。

哪个更好读取excel文件?



是否可以通过任何方式停止 COM 异常?

Hi All,

I want to read data from an excel file and want to store it in a datatable. Previously I was using interop excel.But it give COM exception many time.So I want to switch to OPENXML. But I am unable to read xls file in it .It is showing Corrupted data exception.Any 1 has sample code to fix it.
Which is better to read excel file ?

Is dere any way to stop COM exception ?

推荐答案

通过OLEDB连接Excel:

如何使用ASP.NET,ADO.NET和Visual C#查询和显示Excel数据。 NET



使用NPOI的Excel连接:

NPOI



希望它有所帮助。
Excel connection via OLEDB:
How to query and display excel data by using ASP.NET, ADO.NET, and Visual C# .NET

Excel connectivity using NPOI:
NPOI

Hope it helps.


我不知道。我使用ADO.net,OleDB和Jet或ACE引擎来读写Excel,就像数据库一样。



http://www.microsoft.com/en-us/download/details.aspx?id=13255 [ ^ ]



http://www.connectionstrings.com/excel/ [ ^ ]
I don't know. I use ADO.net, OleDB, and the Jet or ACE engine to read and write Excel like a database.

http://www.microsoft.com/en-us/download/details.aspx?id=13255[^]

http://www.connectionstrings.com/excel/[^]


全部感谢您的回复。



是否可以通过任何方式管理OPENXML中的xls,xlsx文件?
Thanks all for your response.

Is dere any way to manage xls, xlsx file in OPENXML?


这篇关于如何使用OPENXML将Excel数据读取到数据表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆