将一个excel文件的工作表单元格与数据复制到C#中同一单元格中的其他excelfile工作表 [英] Copy one excel file's worksheet cell with data to other excelfile worksheet in same cell in C#

查看:122
本文介绍了将一个excel文件的工作表单元格与数据复制到C#中同一单元格中的其他excelfile工作表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将一些数据导出到excel文件。所以文件来了。其他excel文件有相同的单元格。我想借助c#将包含一个文件数据的单元格复制到其他excel文件中。我怎么能这样做。



我尝试了什么:



我在谷歌搜索但没有合适的结果。

I am exporting some data to excel files. so files came.with Other excel file is there with same cells. I want to copy the cell with data of one file to other excel file with the help of c#. how can I do this.

What I have tried:

I searched in google but no suitable result.

推荐答案

另一种选择是通过Nuget提供的ClosedXML库。

[ ^ ]

这里的一些文档和示例:

主页·ClosedXML / ClosedXML Wiki·GitHub [ ^ ]
Another option is the ClosedXML library available via Nuget.
[^]
Some documentation and examples here:
Home · ClosedXML/ClosedXML Wiki · GitHub[^]


有很多关于在C#中使用OLEDB和/或Excel Interop的文章。请参阅使用MS Excel(xls / xlsx)使用MDAC和Oledb [ ^ ]和如何:使用Visual C#功能访问Office互操作对象(C#编程指南)| Microsoft Docs [ ^ ]。
There are plenty of articles on using OLEDB and/or Excel Interop in C#. See Working with MS Excel(xls / xlsx) Using MDAC and Oledb[^] and How to: Access Office Interop Objects by Using Visual C# Features (C# Programming Guide) | Microsoft Docs[^].


理查德解决方案的附录,这是我使用的简单技巧......



要学习使用C#执行任务的excel命令,打开Excel电子表格,启动宏录制器,手动执行您希望C#app执行的操作,停止宏录制器,并查看excel生成的宏。现在您知道C#app必须执行的命令。
An addendum to Richard's solution, here is a simple trick that I use...

To learn the excel commands to perform the task from C#, open an excel spreadsheet, start the macro recorder, do the actions manually that you want your C# app to perform, stop the macro recorder, and view the macro generated by excel. Now you know the commands that your C# app must perform.


这篇关于将一个excel文件的工作表单元格与数据复制到C#中同一单元格中的其他excelfile工作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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