Skip to main content

TYPE

Returns an integer representing the data type of a value: number = 1; text = 2; logical value = 4; error value = 16; array = 64; compound data = 128.

Syntax

expression.TYPE(arg1);

expression - A variable that represents a ApiWorksheetFunction class.

Parameters

NameRequired/OptionalData typeDefaultDescription
arg1Requirednumber | string | boolean | (number | string | boolean)[] | ApiRange | ApiNameA value to test.

Returns

number

Example

Identify the data type of a cell value and return a numeric code in a spreadsheet.

// How do I determine what type of data is stored in a cell in a spreadsheet?

// Get a numeric identifier that indicates whether a value is text, a number, or a boolean in a spreadsheet.

let worksheet = Api.GetActiveSheet();
let func = Api.WorksheetFunction;
worksheet.GetRange("A1").SetValue(func.TYPE(255));
worksheet.GetRange("A2").SetValue(func.TYPE(true));
worksheet.GetRange("A3").SetValue(func.TYPE("Online Office"));