Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Class

ExcelRangeConditionalFormattingBuilder

OfficeIMO.Excel

Namespace
OfficeIMO.Excel
Assembly
OfficeIMO.Excel
Source revision
273d35d5ba8a with working tree changes
Modifiers
sealed

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

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 optional
True for values above the average; false for values below it.
equalAverage bool = false optional
Whether values equal to the average match.
standardDeviation uint? = null optional
Optional number of standard deviations from the average.
fillColor OfficeIMO.OfficeColor? = null optional
Optional literal or theme-based fill applied when the rule matches.
stopIfTrue bool = false optional
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 optional
stopIfTrue bool = false optional
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 required
Comparison operator.
formula1 string required
Primary value or formula.
formula2 string? = null optional
Secondary value or formula for Between and NotBetween.
fillColor OfficeIMO.OfficeColor? = null optional
Optional literal or theme-based fill applied when the rule matches.
stopIfTrue bool = false optional
Whether lower-priority rules stop when this rule matches.
priority int? = null optional
Optional explicit rule priority.
ColorScale 2 overloads
public ExcelConditionalFormattingInfo ColorScale(OfficeColor startColor, OfficeColor endColor) #

Adds a two-color scale from the minimum to the maximum value.

Parameters

startColor OfficeIMO.OfficeColor required
endColor OfficeIMO.OfficeColor required
public ExcelConditionalFormattingInfo ColorScale(OfficeColor startColor, OfficeColor midColor, OfficeColor endColor) #

Adds a three-color scale with a 50th-percentile midpoint.

Parameters

startColor OfficeIMO.OfficeColor required
midColor OfficeIMO.OfficeColor required
endColor OfficeIMO.OfficeColor required
public ExcelConditionalFormattingInfo DataBar(OfficeColor color) #

Adds a data bar.

Parameters

color OfficeIMO.OfficeColor required
public ExcelConditionalFormattingInfo DuplicateValues(OfficeColor? fillColor = null) #

Adds a duplicate-values rule.

Parameters

fillColor OfficeIMO.OfficeColor? = null optional
public ExcelConditionalFormattingInfo Errors(bool containsErrors = true, bool stopIfTrue = false) #

Adds an errors or, with containsErrors false, a non-errors rule.

Parameters

containsErrors bool = true optional
stopIfTrue bool = false optional
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 required
Formula relative to the top-left cell of the range.
fillColor OfficeIMO.OfficeColor? = null optional
Optional literal or theme-based fill applied when the rule matches.
stopIfTrue bool = false optional
Whether lower-priority rules stop when this rule matches.
priority int? = null optional
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 optional
Icon set, such as ThreeTrafficLights1, FourArrows or FiveRating.
showValue bool = true optional
Whether the cell value is shown next to the icon.
reverseIconOrder bool = false optional
Whether the icon order is reversed.
percentThresholds double[]? = null optional
Optional percent thresholds (0..100), one per icon.
numberThresholds double[]? = null optional
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 required
ContainsText, NotContainsText, BeginsWith or EndsWith.
text string required
Text to match.
fillColor OfficeIMO.OfficeColor? = null optional
Optional literal or theme-based fill applied when the rule matches.
stopIfTrue bool = false optional
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 required
fillColor OfficeIMO.OfficeColor? = null optional
stopIfTrue bool = false optional
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 required
Number of items, or percentage when percent is true.
bottom bool = false optional
True for the lowest values; false for the highest.
percent bool = false optional
Whether rank is a percentage.
fillColor OfficeIMO.OfficeColor? = null optional
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 optional