Удаление строк и столбцов
Contents
[
Hide
]
Эта тема демонстрирует, как удалять строки и столбцы из листа с помощью Aspose.Cells.GridWeb API. С помощью этой функции разработчики могут удалять строки или столбцы во время выполнения.
Удаление строк
Чтобы удалить строку из вашего листа:
- Добавьте элемент управления Aspose.Cells.GridWeb на веб-форму.
- Доступ к листу, из которого вы удаляете строки.
- Удалите строку из листа, указав ее индекс.
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
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// Accessing the reference of the worksheet that is currently active | |
GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
// Get row index entered by user | |
int rowIndex = Convert.ToInt16(txtRowIndex.Text.Trim()); | |
// Delete row at specified index | |
sheet.Cells.DeleteRow(rowIndex); |
Удаление столбцов
Чтобы удалить столбец из вашего листа:
- Добавьте элемент управления Aspose.Cells.GridWeb на веб-форму.
- Доступ к листу, из которого вы хотите удалить столбцы.
- Удалите столбец из листа, указав его индекс.
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
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// Accessing the reference of the worksheet that is currently active | |
GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex]; | |
// Get column index entered by user | |
int columnIndex = Convert.ToInt16(txtColumnIndex.Text.Trim()); | |
// Delete column at specified index | |
sheet.Cells.DeleteColumn(columnIndex); |
Также можно использовать методы DeleteRows/DeleteColumns для удаления нескольких строк/столбцов из листов.