Protect Rows and Columns

Protecting Cells in Rows & Columns

Making Rows & Columns Read Only

One way of protecting rows and columns in a worksheet is to make the cells read only. Then they cannot be deleted by end users.

To make rows and columns read only:

  1. Add the Aspose.Cells.GridWeb control to a Web Form.
  2. Access the GridWorksheet in the collection.
  3. Set your desired cells in rows or columns to read only.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Accessing the first worksheet that is currently active
GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex];
// Set the 1st cell (A1) read only
sheet.SetIsReadonly(sheet.Cells["A1"], true);

Restricting Context Menu Options

Aspose.Cells.GridWeb provides a context menu that end users can use to perform operations on the control. The menu provides many options for manipulating cells, rows and columns.

Complete contextual options

todo:image_alt_text

It is possible to restrict any kind of client side operations on rows and columns by restricting the options available in the context menu. It can be done by setting the EnableClientColumnOperations and EnableClientRowOperations properties of the GridWeb control to false. It is also possible to restrict users from freezing rows and columns by setting the GridWeb control’s EnableClientFreeze property to false.

Context menu after restricting row & column options

todo:image_alt_text

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Restricting column related operations in context menu
GridWeb1.EnableClientColumnOperations = false;
// Restricting row related operations in context menu
GridWeb1.EnableClientRowOperations = false;
// Restricting freeze option of context menu
GridWeb1.EnableClientFreeze = false;