插入行和列

插入行

在工作表的任何位置插入行:

  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);