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