SpreadJS 13
SpreadJS Documentation / Sample Code / Sample Code for Cells / Locking Cells
In This Topic
    Locking Cells
    In This Topic

    You can lock cells.

    Using Code

    This example locks cells and protects the sheet.

    Example Title
    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