-
Notifications
You must be signed in to change notification settings - Fork 599
excel containstext
goworm edited this page Jun 26, 2026
·
1 revision
A conditional formatting rule that matches cells whose text contains a substring (case-insensitive).
Path: /SheetName/cf[N]
Parent: /{SheetName}
| 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. |
| 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. |
# 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]-
textis required and matching is case-insensitive. -
fill,font.color, andfont.boldare applied as a differential format (dxf); on read-back the rule exposes itsdxfIdrather than the individual format properties. - Use
ref(or its aliasessqref/range) to set the cell range the rule applies to.
- Conditional Formatting - Data bars, color scales, icon sets, and formula-based rules
- Excel Reference - All Excel elements
Based on OfficeCLI v1.0.119