Eliminar Rangos
Introducción
En Excel, puedes seleccionar un rango, luego eliminarlo y desplazar otros datos a la izquierda o hacia arriba.
Eliminar Rangos Usando Aspose.Cells
Aspose.Cells proporciona el método Cells.DeleteRange para eliminar un rango.
Eliminar Rangos y Desplazar Celdas a la Izquierda
Eliminar un rango y desplazar las celdas a la izquierda según los siguientes códigos con Aspose.Cells:
// Instantiate a new Workbook. | |
Workbook workbook = new Workbook(); | |
// Get all the worksheets in the book. | |
WorksheetCollection worksheets = workbook.Worksheets; | |
// Get the first worksheet in the worksheets collection. | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Gets cells. | |
Cells cells = worksheet.Cells; | |
// Input some data with some formattings into | |
// A few cells in the range. | |
cells["C2"].PutValue("C2"); | |
cells["C3"].PutValue("C3"); | |
CellArea ca = CellArea.CreateCellArea("B2", "B3"); | |
cells.DeleteRange(ca.StartRow, ca.StartColumn, ca.EndRow, ca.EndColumn, ShiftType.Left); | |
Console.WriteLine(worksheet.Cells["B2"].StringValue == "C2"); | |
Eliminar rangos y desplazar celdas hacia arriba
Eliminar un rango y desplazar celdas hacia arriba como en los siguientes códigos con Aspose.Cells:
// Instantiate a new Workbook. | |
Workbook workbook = new Workbook(); | |
// Get all the worksheets in the book. | |
WorksheetCollection worksheets = workbook.Worksheets; | |
// Get the first worksheet in the worksheets collection. | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Gets cells. | |
Cells cells = worksheet.Cells; | |
// Input some data with some formattings into | |
// A few cells in the range. | |
cells["B4"].PutValue("B4"); | |
cells["B5"].PutValue("B5"); | |
CellArea ca = CellArea.CreateCellArea("B2", "B3"); | |
cells.DeleteRange(ca.StartRow, ca.StartColumn, ca.EndRow, ca.EndColumn, ShiftType.Up); | |
Console.WriteLine(worksheet.Cells["B2"].StringValue == "B4"); |