Cut and Paste Range
Contents
[
Hide
]
Cut and Paste Cells
Aspose.Cells provides you with the ability to cut and paste cells within a worksheet by using the **insert_cut_cells ** method of the Cells collection. The **insert_cut_cells ** accepts the following parameters.
- Range: The range of cells to be cut.
- Row Index: The index of the row to insert cells.
- Column Index: The index of the column to insert cells.
- ShiftType: The shift direction of the columns.
The following example shows how to cut and paste cells within a worksheet.
Sample Code
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
from aspose.cells import ShiftType, Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Source directory | |
outDir = RunExamples.Get_OutputDirectory() | |
workbook = Workbook() | |
worksheet = workbook.worksheets[0] | |
worksheet.cells.get(0, 2).value = 1 | |
worksheet.cells.get(1, 2).value = 2 | |
worksheet.cells.get(2, 2).value = 3 | |
worksheet.cells.get(2, 3).value = 4 | |
worksheet.cells.create_range(0, 2, 3, 1).name = "NamedRange" | |
cut = worksheet.cells.create_range("C:C") | |
worksheet.cells.insert_cut_cells(cut, 0, 1, ShiftType.RIGHT) | |
workbook.save(outDir + "CutAndPasteCells.xlsx") |