Skip to main content

setFormat()

sets a specified format to the value of a cell

setFormat: (cell: string, format: string | string[]) => void;

Parameters:

  • cell: string - the id(s) of a cell(s) or a range of cells
  • format: string | array - the name(s) of the number format to apply to cells value

Example

// applies the currency format to the cell A1
spreadsheet.setFormat("A1","currency");

Starting with v4.1, the reference to a cell can be specified in the following format:

spreadsheet.setFormat("sheet1!A2", "number"); 

where sheet1 is the name of the tab.

In case the name of the tab isn't specified, the method will set the format to the value of a cell of the active tab.

Related articles

Number formatting