Add Protection in Worksheet

Protect Cell using Aspose.Cells.GridDesktop

The following sample code protects all the cells in range A1:B1 of the active worksheet of GridDesktop. When you will double click any cell in this range, you will not able to edit. It will make these cells readonly.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Accessing the worksheet of the Grid that is currently active
Worksheet sheet = gridDesktop1.GetActiveWorksheet();
// Make sure sheet has been protected
sheet.Protected = true;
// Choose a cell range
CellRange range = sheet.CreateRange("A1", "B1");
// Set protected range area on Worksheet
sheet.SetProtected(range, true);