简体   繁体   English

将特定的列从一个Excel电子表格复制到C#中的另一列

[英]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.

相关问题 如何使用C#将一个Excel工作簿中特定范围的单元格复制到另一工作簿中 - how to copy cells from a specific range from one excel workbook to another workbook using c# 如何将特定单元格(带有值、颜色、字体)从一个 excel 文件复制到另一个 excel 文件 C#? - How can I copy specific cells(with Value,Color,Font) from one excel file to another excel file C#? 将特定列从一个 DataTable 复制到另一个 - Copy specific columns from one DataTable to another 将特定的DataSet列复制到C#中的另一个DataSet - Copy specific DataSet columns to another DataSet in C# 如何使用C#在Excel中将一行的格式复制到另一行 - How to copy format of one row to another row in Excel with c# 如何将Excel列从一个文件复制到另一个文件? - How to copy excel columns from one file to another? C# - 如何将单个 Excel 工作表从一个工作簿复制到另一个工作簿? - C# - How to copy a single Excel worksheet from one workbook to another? 如何使用 C# 将选定列的所有行从一个 excel 文件复制到另一个文件 - How to copy all the rows of selected column from one excel file to another using C# CSharp DocumentFormat.OpenXML和Excel-将工作表中的数据从一个电子表格复制到另一个电子表格(具有代码) - CSharp DocumentFormat.OpenXML and Excel - Copy Data in Worksheet from one spreadsheet to another (Have code) 在C#中将一本Excel书中的列插入到另一本Excel书中 - Insert columns form one excel book to another in C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM