Class ConditionalFormat
cellIs (operator +
formula), expression, top-N / above-average, duplicate / unique
values, blank / error presence, notContainsText, and "date
occurring" (timePeriod) rules — each with a differential format
(fill, font color, bold / italic / underline / strikethrough, number format,
and borders) — plus the visual color-scale / data-bar / icon-set kinds.
Apply with Range.addConditionalFormat(...).
The visual kinds carry their full configuration (ECMA-376 §18.3.1.11
cfvo, §18.3.1.16 colorScale, §18.3.1.28 dataBar, §18.3.1.49 iconSet):
threshold ConditionalFormat.ValueObjects, showValue(), icon-set
reverse(), and the data-bar extension detail (gradient / border /
negative-value / axis colors). A rule read from
Sheet.conditionalFormats() can be re-issued through
Range.addConditionalFormat(...). A rule read back reports only the first
range it covers (firstRow() ...), so re-issuing a rule that covers
several ranges covers that first range only.
Builder methods that take a Color accept only RGB colors and throw
IllegalStateException for a theme, indexed or automatic color.
Rule kinds and operators are checked only when the rule is added.
sheet.range("C2:C50").addConditionalFormat(ConditionalFormat.builder()
.cellIs("greaterThan", "100")
.fillColor(Color.of(0xFFFFC7CE))
.bold()
.build());
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA fluent builder for aConditionalFormat.static final recordA threshold value object of a color-scale / data-bar / icon-set rule (ECMA-376 §18.3.1.11 cfvo). -
Method Summary
Modifier and TypeMethodDescriptionThe data-bar axis color token, ornull.The data-bar axis position (automatic/middle/none), ornull.The data-bar border color token, ornullwhen borderless.The data-bar direction (context/leftToRight/rightToLeft), ornull.static ConditionalFormat.Builderbuilder()A builder.The color-scale gradient colors in cfvo order (engine color tokens:#RRGGBBhex, rawAARRGGBBhex,theme:N[:tint],indexed:N); empty for other kinds.The data-bar fill color token, ornullfor other kinds.intThe first column of the rule's first range (0-based, inclusive); 0 for a rule that was built, not read back.intfirstRow()The first row of the rule's first range (0-based, inclusive).formula1()The first formula, without a leading=and without_xlfn.prefixes, ornullwhen none is set.formula2()The second formula of abetween/notBetweenrule, ornullwhen none is set.static ConditionalFormatBuilds a rule from the engine's JSON, the form behindSheet.conditionalFormats().gradient()falsewhen a data bar paints a solid fill instead of the default gradient;nullwhen the source did not specify.The icon-set name (e.g.intThe last column of the rule's first range (0-based, inclusive); 0 for a rule that was built, not read back.intlastRow()The last row of the rule's first range (0-based, inclusive); 0 for a rule that was built, not read back.The negative-value bar border color token, ornull.The negative-value bar fill color token, ornull.operator()ThecellIsoperator, such asgreaterThanorbetween; an empty string when the rule has none.intpriority()Evaluation priority: 1 is evaluated first; 0 when unset.booleanreverse()Whether an icon set draws its icons in reversed order.booleanWhether the cell value is shown beside a data bar / icon set (ECMA-376 defaulttrue; meaningful for those kinds only).booleanWhether lower-priority rules stop evaluating once this one matches.text()The text operand of anotContainsTextrule, ornull.The date window of atimePeriodrule, ornull.A builder pre-loaded with this rule, for read–modify–write round-trips.toJson()The rule as the JSON object sent to the engine.type()The rule kind:cellIs,expression,colorScale,dataBar,iconSet,top10,aboveAverage,duplicateValues,uniqueValues,containsBlanks,notContainsBlanks,containsErrors,notContainsErrors,notContainsTextortimePeriod; an empty string when unset.The threshold value objects of a color-scale / data-bar / icon-set rule, in document order; empty for the non-visual kinds.
-
Method Details
-
builder
A builder. Call one rule-kind method (cellIs,expression,colorScale, ...), then style methods, thenConditionalFormat.Builder.build(). -
toBuilder
A builder pre-loaded with this rule, for read–modify–write round-trips. -
toJson
The rule as the JSON object sent to the engine. Used by the SDK. -
fromJson
Builds a rule from the engine's JSON, the form behindSheet.conditionalFormats(). Used by the SDK. -
type
The rule kind:cellIs,expression,colorScale,dataBar,iconSet,top10,aboveAverage,duplicateValues,uniqueValues,containsBlanks,notContainsBlanks,containsErrors,notContainsErrors,notContainsTextortimePeriod; an empty string when unset. -
operator
ThecellIsoperator, such asgreaterThanorbetween; an empty string when the rule has none. -
formula1
The first formula, without a leading=and without_xlfn.prefixes, ornullwhen none is set. For the blank, error, text and time-period kinds of a read-back rule, it is the formula Excel stores. -
formula2
The second formula of abetween/notBetweenrule, ornullwhen none is set. -
text
The text operand of anotContainsTextrule, ornull. -
timePeriod
The date window of atimePeriodrule, ornull. -
priority
public int priority()Evaluation priority: 1 is evaluated first; 0 when unset. -
stopIfTrue
public boolean stopIfTrue()Whether lower-priority rules stop evaluating once this one matches. -
valueObjects
The threshold value objects of a color-scale / data-bar / icon-set rule, in document order; empty for the non-visual kinds. -
showValue
public boolean showValue()Whether the cell value is shown beside a data bar / icon set (ECMA-376 defaulttrue; meaningful for those kinds only). -
reverse
public boolean reverse()Whether an icon set draws its icons in reversed order. -
colorScaleColors
The color-scale gradient colors in cfvo order (engine color tokens:#RRGGBBhex, rawAARRGGBBhex,theme:N[:tint],indexed:N); empty for other kinds. -
dataBarColor
The data-bar fill color token, ornullfor other kinds. -
iconSetName
The icon-set name (e.g."3Arrows"), ornull. -
gradient
falsewhen a data bar paints a solid fill instead of the default gradient;nullwhen the source did not specify. -
axisPosition
The data-bar axis position (automatic/middle/none), ornull. -
barDirection
The data-bar direction (context/leftToRight/rightToLeft), ornull. -
barBorderColor
The data-bar border color token, ornullwhen borderless. -
negativeFillColor
The negative-value bar fill color token, ornull. -
negativeBorderColor
The negative-value bar border color token, ornull. -
axisColor
The data-bar axis color token, ornull. -
firstRow
public int firstRow()The first row of the rule's first range (0-based, inclusive). A rule that covers several ranges reports only its first range, so re-issuing it covers that range only. 0 for a rule that was built, not read back. -
firstColumn
public int firstColumn()The first column of the rule's first range (0-based, inclusive); 0 for a rule that was built, not read back. -
lastRow
public int lastRow()The last row of the rule's first range (0-based, inclusive); 0 for a rule that was built, not read back. -
lastColumn
public int lastColumn()The last column of the rule's first range (0-based, inclusive); 0 for a rule that was built, not read back.
-