Protect Cells
Contents
[
Hide
]
This topic describes a few techniques for protecting cells. Using these techniques allows developers to restrict users from editing all or a selected range of cells in a worksheet.
Protecting Cells
Aspose.Cells.GridWeb provides a few different techniques for controlling the protection level on cells when the control is in Edit mode (the default mode). This protects cells from being modified by end users.
Making All Cells Read Only
To set all cells in a worksheet to read only, call the worksheet’s SetAllCellsReadonly method.
Making All Cells Editable
To remove protection from all cells, call the worksheet’s SetAllCellsEditable method. This method has the opposite effect to the SetAllCellsReadonly method.
Making Selected Cells Read Only
To protect only a range of cells:
- First make all cells editable by calling the SetAllCellsEditable method.
- Specify the range of cells that to protect by calling the worksheet’s SetReadonlyRange method. This method takes the number of rows and columns to specify the range of cells.
Making Selected Cells Editable
To un-protect a range of cells:
- Make all cells read only by calling the SetAllCellsReadonly method.
- Specify the range of cells that to be editable by calling the worksheet’s SetEditableRange method. This method takes the number of rows and columns to specify the range of cells.