ExcelRangeConditionalFormattingBuilder
OfficeIMO.Excel
Adds conditional formatting rules to an ExcelRange. Each method adds one native rule and returns it attached to the worksheet; edit it with ExcelSheet.UpdateConditionalFormattingRule.
Inheritance
- object
- ExcelRangeConditionalFormattingBuilder
Remarks
Existing rules are listed, updated, cloned, reordered and removed through the worksheet (ExcelSheet.GetConditionalFormattingRules, ExcelSheet.ClearConditionalFormatting). ExcelSheet.AddConditionalFormattingRule adds a rule from the full rule model, including multi-area ranges and Office 2010 extension rules.
Usage
Explore 1 API references to this type
This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.
Returned or exposed by 1
- Method ExcelRange.ConditionalFormat
Methods
public ExcelConditionalFormattingInfo AboveAverage(bool aboveAverage = true, bool equalAverage = false, uint? standardDeviation = null, OfficeColor? fillColor = null, bool stopIfTrue = false) #Adds an above-average or, with aboveAverage false, a below-average rule.
Parameters
- aboveAverage bool = true
- True for values above the average; false for values below it.
- equalAverage bool = false
- Whether values equal to the average match.
- standardDeviation uint? = null
- Optional number of standard deviations from the average.
- fillColor OfficeIMO.OfficeColor? = null
- Optional literal or theme-based fill applied when the rule matches.
- stopIfTrue bool = false
- Whether lower-priority rules stop when this rule matches.
public ExcelConditionalFormattingInfo Blanks(bool containsBlanks = true, bool stopIfTrue = false) #Adds a blanks or, with containsBlanks false, a non-blanks rule.
Parameters
- containsBlanks bool = true
- stopIfTrue bool = false
public ExcelConditionalFormattingInfo CellIs(ExcelConditionalFormattingOperator operator, string formula1, string? formula2 = null, OfficeColor? fillColor = null, bool stopIfTrue = false, int? priority = null) #Adds a cell-value comparison rule, such as greater than, between or equal.
Parameters
- operator OfficeIMO.Excel.ExcelConditionalFormattingOperator
- Comparison operator.
- formula1 string
- Primary value or formula.
- formula2 string? = null
- Secondary value or formula for Between and NotBetween.
- fillColor OfficeIMO.OfficeColor? = null
- Optional literal or theme-based fill applied when the rule matches.
- stopIfTrue bool = false
- Whether lower-priority rules stop when this rule matches.
- priority int? = null
- Optional explicit rule priority.
public ExcelConditionalFormattingInfo ColorScale(OfficeColor startColor, OfficeColor endColor) #Adds a two-color scale from the minimum to the maximum value.
Parameters
- startColor OfficeIMO.OfficeColor
- endColor OfficeIMO.OfficeColor
public ExcelConditionalFormattingInfo ColorScale(OfficeColor startColor, OfficeColor midColor, OfficeColor endColor) #Adds a three-color scale with a 50th-percentile midpoint.
Parameters
- startColor OfficeIMO.OfficeColor
- midColor OfficeIMO.OfficeColor
- endColor OfficeIMO.OfficeColor
public ExcelConditionalFormattingInfo DataBar(OfficeColor color) #Adds a data bar.
Parameters
- color OfficeIMO.OfficeColor
public ExcelConditionalFormattingInfo DuplicateValues(OfficeColor? fillColor = null) #Adds a duplicate-values rule.
Parameters
- fillColor OfficeIMO.OfficeColor? = null
public ExcelConditionalFormattingInfo Errors(bool containsErrors = true, bool stopIfTrue = false) #Adds an errors or, with containsErrors false, a non-errors rule.
Parameters
- containsErrors bool = true
- stopIfTrue bool = false
public ExcelConditionalFormattingInfo Formula(string formula, OfficeColor? fillColor = null, bool stopIfTrue = false, int? priority = null) #Adds a formula rule that matches when the formula evaluates to true for the top-left cell.
Parameters
- formula string
- Formula relative to the top-left cell of the range.
- fillColor OfficeIMO.OfficeColor? = null
- Optional literal or theme-based fill applied when the rule matches.
- stopIfTrue bool = false
- Whether lower-priority rules stop when this rule matches.
- priority int? = null
- Optional explicit rule priority.
public ExcelConditionalFormattingInfo IconSet(ExcelIconSet iconSet = ThreeTrafficLights1, bool showValue = true, bool reverseIconOrder = false, double[]? percentThresholds = null, double[]? numberThresholds = null) #Adds an icon set.
Parameters
- iconSet OfficeIMO.Excel.ExcelIconSet = ThreeTrafficLights1
- Icon set, such as ThreeTrafficLights1, FourArrows or FiveRating.
- showValue bool = true
- Whether the cell value is shown next to the icon.
- reverseIconOrder bool = false
- Whether the icon order is reversed.
- percentThresholds double[]? = null
- Optional percent thresholds (0..100), one per icon.
- numberThresholds double[]? = null
- Optional number thresholds, one per icon; used instead of percent thresholds.
public ExcelConditionalFormattingInfo Text(ExcelConditionalFormatType type, string text, OfficeColor? fillColor = null, bool stopIfTrue = false) #Adds a text rule: contains, does not contain, begins with or ends with.
Parameters
- type OfficeIMO.Excel.ExcelConditionalFormatType
- ContainsText, NotContainsText, BeginsWith or EndsWith.
- text string
- Text to match.
- fillColor OfficeIMO.OfficeColor? = null
- Optional literal or theme-based fill applied when the rule matches.
- stopIfTrue bool = false
- Whether lower-priority rules stop when this rule matches.
public ExcelConditionalFormattingInfo TimePeriod(ExcelConditionalTimePeriod timePeriod, OfficeColor? fillColor = null, bool stopIfTrue = false) #Adds a date rule for a time period such as yesterday, this week or last month.
Parameters
- timePeriod OfficeIMO.Excel.ExcelConditionalTimePeriod
- fillColor OfficeIMO.OfficeColor? = null
- stopIfTrue bool = false
public ExcelConditionalFormattingInfo TopBottom(uint rank, bool bottom = false, bool percent = false, OfficeColor? fillColor = null) #Adds a top or bottom N (or N percent) rule.
Parameters
- rank uint
- Number of items, or percentage when percent is true.
- bottom bool = false
- True for the lowest values; false for the highest.
- percent bool = false
- Whether rank is a percentage.
- fillColor OfficeIMO.OfficeColor? = null
- Optional literal or theme-based fill applied when the rule matches.
public ExcelConditionalFormattingInfo UniqueValues(OfficeColor? fillColor = null) #Adds a unique-values rule.
Parameters
- fillColor OfficeIMO.OfficeColor? = null