Вставка строк и столбцов
Contents
[
Hide
]
В этом разделе объясняется, как вставлять новые строки и столбцы на лист с помощью Aspose.Cells.GridWeb API. Строки и столбцы можно вставлять в любое место на листе.
Вставка строк
Чтобы вставить строку в любое место на листе:
- Добавьте элемент управления Aspose.Cells.GridWeb в веб-форму.
- Получите доступ к рабочему листу, на который вы добавляете строки.
- Вставьте строку, указав индекс строки, куда будет вставлена строка.
This file contains hidden or 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()); | |
// Add row at specified index | |
sheet.Cells.InsertRow(rowIndex); |
Вставка столбцов
Чтобы вставить столбец в любое место на листе:
- Добавьте элемент управления Aspose.Cells.GridWeb в веб-форму.
- Получите доступ к рабочему листу, на который вы добавляете столбцы.
- Вставьте столбец, указав индекс столбца, в который будет вставлен столбец.
This file contains hidden or 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()); | |
// Add column at specified index | |
sheet.Cells.InsertColumn(columnIndex); |
Вы также можете использовать методы InsertRows/InsertColumns для соответствующей вставки нескольких строк/столбцов в рабочие листы.