SpreadJS Documentation
Locking Cells
SpreadJS Documentation > Sample Code > Sample Code for Cells > Locking Cells

You can lock cells.

Using Code

This example locks cells and protects the sheet.

JavaScript
Copy Code

window.onload = function(){
       var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"),{sheetCount:3});
       var activeSheet = spread.getActiveSheet();

//unlock the entire column 1.
activeSheet.getRange(-1, 2, -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(false);
//unlock cell(1,3).
activeSheet.getCell(1, 3, GC.Spread.Sheets.SheetArea.viewport).locked(false);
activeSheet.getCell(1, 3, GC.Spread.Sheets.SheetArea.viewport).value("unlocked");
//Protect the sheet, then cells can only be edited when they are unlocked.
activeSheet.options.isProtected = true;
                 }

See Also

Developer's Guide