Skip to main content

GetType

Returns the type of the color scale conditional formatting rule.

Syntax

expression.GetType();

expression - A variable that represents a ApiColorScale class.

Parameters

This method doesn't have any parameters.

Returns

XlFormatConditionType

Example

Read the category label that identifies what kind of conditional formatting rule is active in a spreadsheet.

// How do I confirm that a formatting rule is a color scale and not another rule type in a spreadsheet?

// Verify the rule category assigned to a color gradient condition before processing it in a spreadsheet.

let worksheet = Api.GetActiveSheet();

worksheet.GetRange("A1").SetValue("Test Data");
worksheet.GetRange("A2").SetValue(10);
worksheet.GetRange("A3").SetValue(30);
worksheet.GetRange("A4").SetValue(50);
worksheet.GetRange("A5").SetValue(70);
worksheet.GetRange("A6").SetValue(90);

let dataRange = worksheet.GetRange("A2:A6");
let formatConditions = dataRange.GetFormatConditions();

let colorScale = formatConditions.AddColorScale(2);

let conditionType = colorScale.GetType();

worksheet.GetRange("C1").SetValue("Type:");
worksheet.GetRange("C2").SetValue(conditionType);