This page has thin source coverage. Expression syntax and context variables are derived from configuration templates. Verify advanced expression patterns in the application.
Conditional Formatting Chain
Configuration Sections
1. Column References a Formatter
2. Formatter Defines Rules
Each formatter is an array of rules. Each rule has anexpression (JavaScript expression evaluated per cell) and a style name applied when the expression is true.
3. Style Defines Visual Properties
Formatter Rule Properties
| Property | Type | Default | Description |
|---|---|---|---|
formatters.<name> | array | [] | Array of conditional rules |
formatters.<name>[].expression | string | None | JavaScript expression that evaluates to true or false |
formatters.<name>[].style | string | None | Named style to apply when expression is true |
Style Properties
| Property | Type | Default | Description |
|---|---|---|---|
styles.<name>.backgroundColor | string | None | Background color token (e.g., grey100, red200) |
styles.<name>.color | string | None | Text color token (e.g., grey700, red700) |
styles.<name>.fontWeight | number | None | Font weight (e.g., 600) |
styles.<name>.textDecoration | string | None | Text decoration (e.g., line-through) |
Unconditional Formatting
Apply a style to every cell in the column regardless of value:Using Predefined Styles
All 20 predefined styles can be used in formatter rules without defining them in thestyles section:
| Style | Appearance |
|---|---|
none | No styling |
boldTitle | Font weight 600 |
readOnly | Read-only visual indicator |
unsupported | Grey background with strikethrough |
grey, darkgrey | Grey shades |
red, darkred | Red shades |
orange, darkorange | Orange shades |
green, darkgreen, lightgreen | Green shades |
blue, darkblue, lightblue | Blue shades |
teal, darkteal | Teal shades |
purple, darkpurple, lightpurple | Purple shades |
Multiple Formatters on One Column
A column can only reference one formatter name, but that formatter can contain multiple rules:The exact
context object available within formatter expressions depends on the runtime. Common patterns include context.value for the current cell value and context.item for the row entity.Decision Matrix: Choosing the Right Approach
| Requirement | Approach | Example |
|---|---|---|
| Always apply same style | Unconditional formatter with expression: 'true' | Read-only columns |
| Style based on cell value | Conditional expression | Severity coloring |
| Color-code column headers | Use header.style instead | See Header Styles |
| Color-code column groups | Use groupStyle on column group | See Column Groups |
Complete YAML Example
Related Pages
- Formatters — detailed formatter section reference
- Styles — style definitions and color token reference
- Column Properties — the
formattercolumn property - Header Styles — header-specific styling (not conditional)
Source references: powersheet.yaml, whole_rtm.template.yaml, ConfigProvider.tsx (DEFAULT_STYLES)
Sources
Sources
KB ArticlesSource Code
powersheet.yamlprod-powersheet-src/com.nextedy.powersheet.client/ltc-repo/packages/common/types/api/document.tsprod-powersheet-src/com.nextedy.powersheet.client/cypress/fixtures/configurations/whole_rtm.template.yamlprod-powersheet-src/com.nextedy.powersheet.client/ltc-repo/packages/sheet/commands/exportXlsx.tsxprod-powersheet-src/com.nextedy.powersheet.client/ltc-repo/packages/sheet/SheetComponent.tsx