Удалить диапазоны
Contents
[
Hide
]
Введение
В Excel можно выбрать диапазон, затем удалить его и сдвинуть другие данные влево или вверх.
Удаление диапазонов с помощью Aspose.Cells
Aspose.Cells предоставляет метод Cells.DeleteRange для удаления диапазона.
Удалить диапазоны и сдвинуть ячейки влево
Удалить диапазон и сдвинуть ячейки влево с помощью следующих кодов с Aspose.Cells:
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
// 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(); | |
Удалить диапазоны и сдвинуть ячейки вверх
Удалить диапазон и сдвинуть ячейки вверх с помощью следующих кодов с Aspose.Cells:
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
// 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); |