SpreadJS Documentation
Changing the Active Cell Backcolor
SpreadJS Documentation > Sample Code > Sample Code for Cells > Changing the Active Cell Backcolor

You can change the color of the active cell.

Using Code

This example changes the color of the active cell.

JavaScript
Copy Code

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

sheet.getCell(0, 0).backColor("pink");

     sheet.bind(GC.Spread.Sheets.Events.LeaveCell, function (event, infos) {
         //Reset the backcolor of cell before moving
         infos.sheet.getCell(infos.row, infos.col).backColor(undefined);
     });

     sheet.bind(GC.Spread.Sheets.Events.EnterCell, function (event, infos) {
         //Set the backcolor of destination cells (currently active cells)
         infos.sheet.getCell(infos.row, infos.col).backColor("pink");
     });
                      }

See Also

Developer's Guide