[英]Which is the best way to manipulate data/sheet of an excel document in C#
I'm currently busy with a task that involves both manipulating data in an excising excel document as well as the sheet itself. 我目前正忙于一项任务,该任务涉及处理一个正在删除的excel文档中的数据以及工作表本身。
In the past I've always used OleDbConnection and OleDbCommand to work with excel, but I've been reading about something called a Workbook and I'm not sure which way I should go about this. 过去,我一直使用OleDbConnection和OleDbCommand来与excel一起使用,但是我一直在阅读一种称为“工作簿”的东西,我不确定应该采用哪种方法。
Some examples of what I need to do include- 我需要做的一些例子包括:
In your option which way would be the most efficient way to go about this. 您可以选择哪种方式是解决此问题的最有效方法。 Thanks
谢谢
Best way would be to go with excel interop
if you don't want to use any third party library. 如果您不想使用任何第三方库,最好的方法是使用
excel interop
。
Interop
works and any action can be performed which you have mentioned in your question. Interop
工作以及可以执行的问题中提到的任何操作。
Refer this link for more info: http://csharp.net-informations.com/excel/csharp-excel-tutorial.htm 请参阅此链接以获取更多信息: http : //csharp.net-informations.com/excel/csharp-excel-tutorial.htm
PS: above link is for c# and for interop to work ms excel must be installed on the system, this can be implemented in vb.net as well.
PS:
above link is for c# and for interop to work ms excel must be installed on the system, this can be implemented in vb.net as well.
Hope this helps. 希望这可以帮助。
I have used Visual Studio Tools for Office, you will have workbooks, worksheets, columns, ranges, etc. Easy to manipulate using C#. 我已经使用了Visual Studio Tools for Office,您将拥有工作簿,工作表,列,范围等。使用C#易于操作。
https://msdn.microsoft.com/en-us/library/bb608603.aspx https://msdn.microsoft.com/zh-CN/library/bb608603.aspx
将此软件包安装到您的项目中进一步无需安装Excel,这也是快速的方法https://www.nuget.org/packages/ExcelDataReader/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.