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

XL.Sheet.AddConditionalFormatting

Adds a conditional formatting rules to the sheet.

Component Version macOS Windows Linux Server iOS SDK
XL 14.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "XL.Sheet.AddConditionalFormatting"; bookRef; sheetIndex )   More

Parameters

Parameter Description Example
bookRef The reference to the workbook. Please use XL.LoadBook to load a file. $ref
sheetIndex The index of the sheet. This number ranges from 0 to XL.Book.SheetCount-1. 0

Result

Returns conditional formatting index number or error.

Description

Adds a conditional formatting rules to the sheet.
Requires LibXL 4.1 and only for xlsx files.

Examples

Highlighting alternating rows:

# add conditional format
Set Variable [ $cFormat ; Value: MBS("XL.Book.AddConditionalFormat"; $book) ]
Set Variable [ $r ; Value: MBS("XL.ConditionalFormat.SetFillPattern"; $book; $cFormat; 1 /* solid */) ]
Set Variable [ $r ; Value: MBS("XL.ConditionalFormat.SetPatternBackgroundColor"; $book; $cFormat; MBS("XL.Color.Pack"; $book; 240; 240; 240)) ]
#
Set Variable [ $CF ; Value: MBS("XL.Sheet.addConditionalFormatting"; $book; $sheet) ]
Set Variable [ $r ; Value: MBS("XL.ConditionalFormating.AddRange"; $book; $CF; 4; 20; 1; 10) ]
Set Variable [ $r ; Value: MBS("XL.ConditionalFormating.AddRule"; $book; $CF; 6 /* Expression */; $cFormat; "=MOD(ROW(),2)=0") ]

See also

Release notes

Blog Entries

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


XL.NewBook - XL.Sheet.AddDataValidation