插入行和列

插入行

要在工作表中的任意位置插入一行:

  1. 将 Aspose.Cells.GridWeb 控件添加到 Web 窗体。
  2. 访问要向其添加行的工作表。
  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);

插入列

要在工作表中的任意位置插入一列:

  1. 将 Aspose.Cells.GridWeb 控件添加到 Web 窗体。
  2. 访问要向其添加列的工作表。
  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);