Skip to content

excel containstext

goworm edited this page Jun 26, 2026 · 1 revision

Excel: Contains Text

A conditional formatting rule that matches cells whose text contains a substring (case-insensitive).

Path: /SheetName/cf[N]

Operations

  • add - Create a contains-text conditional formatting rule
  • get - Read back a rule's attributes

add

Parent: /{SheetName}

Properties

Property Required/Default Description
ref Target cell range. Aliases: sqref, range.
text yes Substring to match (case-insensitive).
fill Background fill color via dxf.
font.color Font color via dxf.
font.bold Bold via dxf.
stopIfTrue Stop evaluating subsequent CF rules when this rule applies.

get Attributes

Attribute Type Description
ref string Target cell range.
text string Matched substring.
type string Canonical CF rule type token (e.g. containsText). Emitted on every CF rule.
dxfId number Differential format id referencing dxf styles. Emitted only when present on the rule.

Examples

# Highlight cells containing "error" with a light-red fill
officecli add data.xlsx /Sheet1/cf --type containstext \
  --prop sqref=A1:A100 --prop text=error --prop fill=FFCCCC

# Match using the ref alias and apply a red, bold font
officecli add data.xlsx /Sheet1/cf --type containstext \
  --prop ref=A1:A100 --prop text=error \
  --prop font.color=FF0000 --prop font.bold=true

# Stop evaluating later CF rules once this one matches
officecli add data.xlsx /Sheet1/cf --type containstext \
  --prop ref=B1:B50 --prop text=fail \
  --prop fill=FFCCCC --prop stopIfTrue=true

# Read back a rule
officecli get data.xlsx /Sheet1/cf[1]

Notes

  • text is required and matching is case-insensitive.
  • fill, font.color, and font.bold are applied as a differential format (dxf); on read-back the rule exposes its dxfId rather than the individual format properties.
  • Use ref (or its aliases sqref / range) to set the cell range the rule applies to.

See Also


Based on OfficeCLI v1.0.119

Clone this wiki locally