setStyle

sets style to a cell(s)

void setStyle(string cells,object|array style);

Parameters

cellsstringthe id of a cell or a range of cells
styleobject|arraystyles that should be applied to cells

Example

// setting style for one cell
spreadsheet.setStyle("A1",{background:"red", border:"solid 1px yellow"});
// setting the same style for a range of cells
spreadsheet.setStyle("A1:D1",{color:"blue"});
// setting the same style for different cells
spreadsheet.setStyle("B6,A1:D1",{color:"blue"});
// setting styles from an array for cells in a range alternately
spreadsheet.setStyle("A1:D1",[{color:"blue"},{color:"red"}]);

Details

The method allows setting the same style for the specified cells. In case you want to apply different cells to spreadsheet cells, you'd better use the parse method.

Related sample:  Styled data

See also
Back to top