Taglia e Incolla Celle
Contents
[
Hide
]
Taglia e Incolla Celle
Aspose.Cells for Python via Java offre la possibilità di tagliare e incollare celle. A questo scopo, l’API fornisce il metodo insertCutCells della collezione Cells. Il metodo insertCutCells accetta i seguenti parametri.
- Range: La gamma di celle da tagliare.
- Indice riga: L’indice della riga in cui inserire le celle.
- Indice colonna: L’indice della colonna in cui inserire le celle.
- ShiftType: la direzione dello spostamento delle colonne.
Il seguente frammento di codice dimostra come tagliare e incollare celle all’interno di un foglio di lavoro.
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
output_directory = "Examples/SampleFiles/OutputDirectory/" | |
# Instantiating a Workbook object | |
workbook = Workbook() | |
# Get the first worksheet | |
worksheet = workbook.getWorksheets().get(0) | |
# Set values | |
worksheet.getCells().get(0, 2).setValue(1) | |
worksheet.getCells().get(1, 2).setValue(2) | |
worksheet.getCells().get(2, 2).setValue(3) | |
worksheet.getCells().get(2, 3).setValue(4) | |
worksheet.getCells().createRange(0, 2, 3, 1).setName("NamedRange") | |
# Cut and paste cells | |
cut = worksheet.getCells().createRange("C:C") | |
worksheet.getCells().insertCutCells(cut, 0, 1, ShiftType.RIGHT) | |
# Save the excel file. | |
workbook.save(output_directory + "CutAndPasteCells.xlsx") |