Delete Rows and Columns
Contents
[
Hide
]
This topic demonstrates how to delete rows and columns from a worksheet using the Aspose.Cells.GridWeb API. With the help of this feature, developers can delete rows or columns at runtime.
Deleting Rows
To delete a row from your worksheet:
- Add the Aspose.Cells.GridWeb control to a Web Form.
- Access the worksheet you are deleting rows from.
- Delete a row from the worksheet by specifying its row index.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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:
- Add the Aspose.Cells.GridWeb control to a Web Form.
- Access the worksheet you want to delete columns from.
- Delete a column from the worksheet by specifying its column index.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
You can also use DeleteRows/DeleteColumns methods to delete multiple rows/columns into the worksheets.