Skip to main content

GetNumberFormat

Returns a value that represents the format code for the current range.

Syntax

expression.GetNumberFormat();

expression - A variable that represents a ApiRange class.

Parameters

This method doesn't have any parameters.

Returns

string | null

Example

Read the number format code applied to a cell range in a spreadsheet.

// How do I find out what number format is set on a range in a spreadsheet?

// Inspect the formatting pattern a range uses to display its values in a spreadsheet.

let worksheet = Api.GetActiveSheet();
let range = worksheet.GetRange("B2");
range.SetValue(3);
let format = range.GetNumberFormat();
worksheet.GetRange("B3").SetValue("Number format: " + format);