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.getWorksheets(); | |
// Get the first worksheet in the worksheets collection. | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
// Get cells. | |
Cells cells = worksheet.getCells(); | |
// Set a few cells in the range. | |
cells.get("C2").putValue("C2"); | |
cells.get("C3").putValue("C3"); | |
CellArea ca = CellArea.createCellArea("B2", "B3"); | |
cells.deleteRange(1,1,2,2, ShiftType.LEFT); | |
String b2 = worksheet.getCells().get("B2").getStringValue(); | |
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.getWorksheets(); | |
// Get the first worksheet in the worksheets collection. | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
// Gets cells. | |
Cells cells = worksheet.getCells(); | |
// Get cells. | |
Cells cells = worksheet.getCells(); | |
// Set a few cells in the range. | |
cells.get("B4").putValue("B4"); | |
cells.get("B5").putValue("B5"); | |
cells.deleteRange(1,1,2,1, ShiftType.UP); |