[英]How do I copy last column value of an excel sheet to another excel sheet's last column using asp.net c#?
This is the image of the last column in an excel sheet that I want to copy to another excel sheet last columm这是 excel 工作表中最后一列的图像,我想将其复制到另一个 excel 工作表最后一列
May I know how to do it using asp.net c# code?我可以知道如何使用 asp.net c# 代码吗?
You can use sheet.Copy() to copy a range from an excel sheet to another excel sheet.您可以使用sheet.Copy()将范围从 excel 工作表复制到另一个 excel 工作表。
Workbook workbook1 = new Workbook();
workbook1.LoadFromFile("file1.xlsx");
Worksheet sheet1 = workbook1.Worksheets[0];
Workbook workbook2 = new Workbook();
workbook2.LoadFromFile("file2.xlsx");
Worksheet sheet2 = workbook2.Worksheets[0];
//copy the last column of sheet1 and insert after the last column of sheet2
sheet2.Copy(sheet1.Range[sheet1.FirstRow, sheet1.LastColumn, sheet1.LastRow, sheet1.LastColumn], sheet2.Range[sheet2.FirstRow, sheet2.LastColumn + 1, sheet2.LastRow, sheet2.LastColumn + 1], true);
workbook2.SaveToFile("copy.xlsx", ExcelVersion.Version2013);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.