[英]Copy specific columns from one excel spreadsheet to another in C#
I have been trying to make a simple app to merge information from one excel spreadsheet to another in c#. 我一直在尝试制作一个简单的应用程序,以在C#中将信息从一个Excel电子表格合并到另一个电子表格。 But I don't find any reference about how could I do this.
但是我找不到有关如何执行此操作的参考。
enter image description here 在此处输入图片说明
I have the info in one spreadsheet and I need to copy that information in another spreadsheet file. 我在一个电子表格中有信息,我需要将该信息复制到另一个电子表格文件中。
enter image description here 在此处输入图片说明
How can do this? 怎么办呢? Thanks in advance.
提前致谢。
Here is another thing you may want to try out (the code uses GemBox.Spreadsheet library ): 这是您可能想尝试的另一件事(代码使用GemBox.Spreadsheet库 ):
ExcelFile source = ExcelFile.Load("Source.xlsx");
ExcelColumn sourceColumn = source.Worksheets[0].Columns[0];
ExcelFile destination = ExcelFile.Load("Destination.xlsx");
ExcelColumn destinationColumn = destination.Worksheets[0].Columns[0];
int count = source.Worksheets[0].Rows.Count;
for (int i = 0; i < count; i++)
destinationColumn.Cells[i].Value = sourceColumn.Cells[i].Value;
destination.Save("Destination.xlsx");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.