剪切和粘贴范围
Contents
[
Hide
]
剪切和粘贴单元格
Aspose.Cells 提供了在工作表中通过使用 InsertCutCells 集合的 Cells 方法剪切和粘贴单元格的功能。InsertCutCells 接受以下参数。
以下示例展示了如何在工作表中剪切和粘贴单元格。
示例代码
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
//Source directory | |
string outDir = RunExamples.Get_OutputDirectory(); | |
Workbook workbook = new Workbook(); | |
Worksheet worksheet = workbook.Worksheets[0]; | |
worksheet.Cells[0, 2].Value = 1; | |
worksheet.Cells[1, 2].Value = 2; | |
worksheet.Cells[2, 2].Value = 3; | |
worksheet.Cells[2, 3].Value = 4; | |
worksheet.Cells.CreateRange(0, 2, 3, 1).Name = "NamedRange"; | |
Range cut = worksheet.Cells.CreateRange("C:C"); | |
worksheet.Cells.InsertCutCells(cut, 0, 1, ShiftType.Right); | |
workbook.Save(outDir + "CutAndPasteCells.xlsx"); |