ConditionalFormat class Worksheet

A conditional formatting rule applied to a cell range.

Create one with a factory and attach it via Sheet.addConditionalFormat:

sheet.addConditionalFormat(
  CellIndex.indexByString('B2'),
  CellIndex.indexByString('B100'),
  ConditionalFormat.greaterThan(100,
      style: CellStyle(fontColorHex: ExcelColor.red)),
);
sheet.addConditionalFormat(start, end,
    ConditionalFormat.colorScale(min: red, mid: yellow, max: green));

Constructors

ConditionalFormat.aboveAverage({required CellStyle style, bool below = false, bool orEqual = false, int? standardDeviations})
Highlight values above the range's average.
factory
ConditionalFormat.beginsWith(String value, {required CellStyle style})
Highlight cells whose text begins with value.
factory
ConditionalFormat.between(num min, num max, {required CellStyle style})
Highlight cells whose value is between min and max (inclusive).
factory
ConditionalFormat.colorScale({required ExcelColor min, ExcelColor? mid, required ExcelColor max})
A 2- or 3-colour scale (heat map). Pass mid for a 3-colour scale.
factory
ConditionalFormat.containsText(String value, {required CellStyle style})
Highlight cells whose text contains value.
factory
ConditionalFormat.dataBar(ExcelColor color)
An in-cell data bar of the given color.
factory
ConditionalFormat.duplicateValues({required CellStyle style})
Highlight values that appear more than once in the range.
factory
ConditionalFormat.endsWith(String value, {required CellStyle style})
Highlight cells whose text ends with value.
factory
ConditionalFormat.equalTo(num value, {required CellStyle style})
Highlight cells equal to value.
factory
ConditionalFormat.formula(String formula, {required CellStyle style})
Highlight cells where the boolean formula is true, e.g. '$B1>$C1'. The formula is relative to the top-left cell of the applied range.
factory
ConditionalFormat.greaterThan(num value, {required CellStyle style})
Highlight cells greater than value.
factory
ConditionalFormat.iconSet(IconSetType iconSet, {bool reverse = false, bool showValue = true, List<double>? thresholds})
An icon set, a small icon (arrows, traffic lights, ratings, ...) drawn in each cell according to where its value falls in the range.
factory
ConditionalFormat.lessThan(num value, {required CellStyle style})
Highlight cells less than value.
factory
ConditionalFormat.notContainsText(String value, {required CellStyle style})
Highlight cells whose text does not contain value.
factory
ConditionalFormat.timePeriod(String period, {required CellStyle style})
Highlight dates falling in period.
factory
ConditionalFormat.top10(int count, {required CellStyle style, bool percent = false, bool bottom = false})
Highlight the top count values in the range.
factory
ConditionalFormat.uniqueValues({required CellStyle style})
Highlight values that appear exactly once in the range.
factory

Properties

aboveAverage bool
For an aboveAverage rule, whether it matches values above the average (true, the default) or below it.
final
colors List<ExcelColor>
The colours of a colour-scale (2 or 3) or data-bar (1) rule.
no setter
equalAverage bool
For an aboveAverage rule, whether values exactly equal to the average also match.
final
formulas List<String>
The rule's formula / threshold operands (0-2 entries).
no setter
hashCode int
The hash code for this object.
no setterinherited
iconReverse bool
For an icon-set rule, whether the icon order is reversed.
final
iconSetName String?
For an icon-set rule, the OOXML icon set name (e.g. '3TrafficLights1'); null for other rule kinds.
final
iconShowValue bool
For an icon-set rule, whether the cell value is shown alongside the icon.
final
iconThresholds List<double>
For an icon-set rule, the threshold values (one per icon) at which each icon takes over, as percentages by default (the first is 0).
final
isThreeColor bool
Whether a colour-scale rule uses three colours (has a midpoint).
no setter
operator String?
The raw OOXML comparison operator for a cellIs rule (e.g. 'greaterThan', 'between'), or null when the rule has none.
no setter
range String?
The range the rule applies to (its sqref, e.g. 'B2:B100'), or null for a bare rule not yet attached to a range. Populated for rules read from a file and for those added via Sheet.addConditionalFormat.
final
rank int?
For a top10 rule, how many items the rule covers.
final
rankFromBottom bool
For a top10 rule, whether the rule selects the bottom N instead of the top N.
final
rankIsPercent bool
For a top10 rule, whether rank is a percentage rather than a count.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stdDev int?
For an aboveAverage rule, the number of standard deviations from the mean the rule applies at; null for a plain above/below average rule.
final
style CellStyle?
The differential style applied when a cellIs / formula rule matches; null for colour-scale and data-bar rules.
final
text String?
For a text rule (containsText, notContainsText, beginsWith, endsWith), the string being looked for; null for other rule kinds.
final
timePeriod String?
For a timePeriod rule, the OOXML period name (today, yesterday, last7Days, thisMonth, ...); null for other rule kinds.
final
type ConditionalFormatType
The rule kind (a ConditionalFormatType; unmodeled kinds read as ConditionalFormatType.other, see typeName for the raw value).
no setter
typeName String
The raw OOXML type of the rule (e.g. 'cellIs', 'expression', 'colorScale', 'dataBar', 'iconSet', 'top10', ...).
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited