Excel& C# [英] Excel & C#

查看:103
本文介绍了Excel& C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


一段时间后,我已经重新开始使用C#进行开发.好像我休息了很长时间.

但是总而言之,我遇到一种情况,我需要通过我正在设计的C#应用​​程序将Excel文件的内容上载到SQL Server表中.

最好的方法是什么?

我已经选择了以下方法

1. Excel Interop
2.将Excel文件转换为csv
3.将Excel文件转换为xml
4. OLE DB

问题
1.推荐的方法是什么?为什么?
2.如何使用以上任何一种方法检查源Excel文件的格式是否正确(缺少列,标题丢失等).我只想说一个一般准则.
3.以上方法(1-4)是否正确?还有其他我错过的方法吗?

欢迎任何回应

提前多谢了

Hi
I have restarted developing in C# after quite some time. It''s like i have taken a long break.

But anyway to get to the point, I have a situation where I need to upload the contents of an Excel file into SQL Server tables through a C# application that i am designing.

What would be the best approach?

I have shortlisted the following methods

1. Excel Interop
2. convert the excel file to csv
3. convert the excel file to xml
4. OLE DB

Questions
1. What would be the recommended approach and why?
2. How can i check using any of the above whether the source Excel file is in the right format (missing columns, header missing etc). I want just a general guideline you might say.
3. Are the above methods (1-4) correct? is there any other method i have missed out?

Any responses are welcome

thanks a ton in advance

推荐答案

嗨.
1.更好地用于为新文档创建丰富的格式.对于只读用途不是很有用.
2.足够快,但是需要额外的转换和验证.
3.足够快,但是需要额外的转换和验证.
4.对我个人而言,这是只读任务的最佳选择.速度非常快(比Interop快一千倍)
Hi.
1. Better use to create rich formatting for new documents. Not very useful for read-only purposes.
2. Fast enough, but requires additional conversion and verification.
3. Fast enough, but requires additional conversion and verification.
4. Personally for me this is the best choice for read-only tasks. It is very quick (thousand times comparatively to Interop)


这篇关于Excel& C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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