Вставить строки и столбцы

Вставка строк

Для вставки строки в любое место на листе Excel:

  1. Добавьте элемент управления Aspose.Cells.GridWeb на веб-форму.
  2. Получите доступ к листу Excel, в который добавляете строки.
  3. Вставьте строку, указав индекс строки, куда будет вставлена строка.
// 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:

  1. Добавьте элемент управления Aspose.Cells.GridWeb на веб-форму.
  2. Получите доступ к листу Excel, в который добавляете столбцы.
  3. Вставьте столбец, указав индекс столбца, куда будет вставлен столбец.
// 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);