Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

XL.ConditionalFormating.Add2ColorScaleRule

Adds a conditional formatting rule that creates a gradated 2-color scale on the cells.

Component Version macOS Windows Linux Server iOS SDK
XL 14.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "XL.ConditionalFormating.Add2ColorScaleRule"; bookRef; ConditionalFormattingRef; minColor; maxColor { ; minType; minValue; maxType; maxValue; stopIfTrue } )   More

Parameters

Parameter Description Example Flags
bookRef The reference to the workbook. Please use XL.LoadBook to load a file. $ref
ConditionalFormattingRef The reference number for the conditional formatting. $ConditionalFormatting
minColor the color for minimum
maxColor the color for maximum
minType the type of minValue, see values below.
Defaults to 0 for CFVO_MIN.
0 Optional
minValue The numeric value for minimum.
Default is 0.
0 Optional
maxType The type of maxValue, see values below.
Defaults to 1 for CFVO_MAX.
1 Optional
maxValue The numeric value for maximum.
Defaults to 0.
0 Optional
stopIfTrue If true, no rules with lower priority may be applied over this rule, when this rule is true.
Defaults to false.
false Optional

Result

Returns OK or error.

Description

Adds a conditional formatting rule that creates a gradated 2-color scale on the cells.
Possible values for minType and maxType parameters:
NameValueDescription
CFVO_MIN0indicates that the minimum value in the range shall be used as the minimum value for the gradient
CFVO_MAX1indicates that the maximum value in the range shall be used as the maximum value for the gradient
CFVO_FORMULA2the minimum/midpoint/maximum value for the gradient is determined by a formula
CFVO_NUMBER3indicates that the minimum/midpoint/maximum value for the gradient is specified by a constant numeric value
CFVO_PERCENT4value indicates a percentage between the minimum and maximum values in the range shall be used as the minimum/midpoint/maximum value for the gradient
CFVO_PERCENTILE5value indicates a percentile ranking in the range shall be used as the minimum/midpoint/maximum value for the gradient

Examples

Add conditional format to color cells based on value:

Set Variable [ $CF ; Value: MBS("XL.Sheet.AddConditionalFormatting"; $book; $sheet) ]
Set Variable [ $r ; Value: MBS("XL.ConditionalFormating.AddRange"; $book; $CF; 3; 10; 2; 2) ]
Set Variable [ $r ; Value: MBS("XL.ConditionalFormating.Add2ColorScaleRule"; $book; $CF; MBS( "XL.Color.Pack"; $book; 255; 133; 40 ); MBS( "XL.Color.Pack"; $book; 255; 239; 156 )) ]

See also

Example Databases

Blog Entries

Created 30th March 2024, last changed 31st March 2024


XL.ConditionalFormating.Add2ColorScaleFormulaRule - XL.ConditionalFormating.Add3ColorScaleFormulaRule