使用C#进行excel操作的İnterop或oledb? [英] İnterop or oledb for excel manipulation with C# ?

查看:86
本文介绍了使用C#进行excel操作的İnterop或oledb?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在研究一个操纵excel数据的项目。



我有一台机器的excel报告给出了我自动提供这些数据。但是这些数据需要进行操作和编辑。



我想要一个程序自动执行此操作。



现在我有2个excel文件。其中一个来自机器,另一个是编辑模板。我想从机器的Excel中找到正确的数据并写入模板。我可以使用id选项来查找数据。当我找到数据时,我需要将这些数据写入同一id栏上的模板。



我看文章,有2种主要方法可做它。其中一个Interop和其他方式是使用OleDb。



现在,excel的版本可以在其他计算机上进行更改,那么哪种方式更好呢?



谢谢。



我的尝试:



我看了网上的文章。

Hello everyone,
I am working on a project for manipulate excel datas.

I have an excel report from a machine gives me this data automatically. But this data needs to be manipulate and edit.

I want to a program for do this automatically.

Now i have 2 excel file. One of them from machine, other one is edited template. I want to find the right data from machine's excels and write to template. I can use id option for the find the data. And when i find the data, i need to write this data to template on the same id column.

I look at the articles and there is 2 main way to do it. One of them Interop and other way is the use OleDb.

Now, excel's versions can be change on other computers, so which way is the better for do this ?

Thank you.

What I have tried:

I looked the articles on the web.

推荐答案

Interop要求在运行你的机器上安装Microsoft Office应用程序 - 如果没有安装,那么Interop根本不起作用。在此基础上,OleDB将是一个更好的通用操作选项。





但是,我也不使用阅读: c# - 从Excel文件中读取数据 - 堆栈溢出 [< a href =http://stackoverflow.com/questions/32999550/read-data-from-an-excel-filetarget =_ blanktitle =New Window> ^ ] - 请参阅Velkumar解决方案,效果非常好。

[/ edit]
Interop requires Microsoft Office installed on the machine that is running your app - if it isn't installed, then Interop will not work at all. On that basis, OleDB would be a better option for a generic operation.

[edit]
However, I don't use either for reading: c# - Read data from an Excel file - Stack Overflow[^] - see the Velkumar solution, it works very nicely.
[/edit]


这篇关于使用C#进行excel操作的İnterop或oledb?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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