Adds a conditional formatting rule to the active sheet of a spreadsheet workbook. Pass a struct with range (A1 cell range), operator (equal, greaterThan, greaterThanOrEqual, lessThan, lessThanOrEqual, notEqual or between, default equal), value (the comparison value) and format (the same format struct keys accepted by formatCell). Alternatively pass { type: "colorScale", range, colors: [ ... ] } with two or three colours to add a colour-scale rule. The fluent member form is addConditionalFormatting({...}).
spreadsheetAddConditionalFormatting(spreadsheetObj, formatStruct)
→ returns any
A cellIs rule that bolds and fills matching cells yellow.
wb = Spreadsheet("xlsx");
spreadsheetAddConditionalFormatting(wb, {
range: "B2:B100",
operator: "greaterThan",
value: "100",
format: { bold: true, bgcolor: "yellow" }
});
A three-colour scale from red to green across a range.
wb = Spreadsheet("xlsx");
spreadsheetAddConditionalFormatting(wb, {
range: "B2:B100",
type: "colorScale",
colors: ["red", "yellow", "green"]
});
Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.