Agregar protección en la hoja de cálculo

Proteger celda usando Aspose.Cells.GridDesktop

El siguiente código de ejemplo protege todas las celdas en el rango A1:B1 de la hoja de cálculo activa de GridDesktop. Cuando haga doble clic en cualquier celda en este rango, no podrá editarla. Estas celdas serán de solo lectura.

// 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);