Delete Rows and Columns

Deleting Rows

To delete a row from your worksheet:

  1. Add the Aspose.Cells.GridWeb control to a Web Form.
  2. Access the worksheet you are deleting rows from.
  3. Delete a row from the worksheet by specifying its row index.
// 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);

Deleting Columns

To delete a column from your worksheet:

  1. Add the Aspose.Cells.GridWeb control to a Web Form.
  2. Access the worksheet you want to delete columns from.
  3. Delete a column from the worksheet by specifying its column index.
// 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);