删除行和列

删除行

要从工作表中删除行:

  1. 将 Aspose.Cells.GridWeb 控件添加到 Web 表单中。 1.访问要从中删除行的工作表。
  2. 通过指定其行索引来从工作表中删除行。
// 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());
// Delete row at specified index
sheet.Cells.DeleteRow(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());
// Delete column at specified index
sheet.Cells.DeleteColumn(columnIndex);