Prerequisites
Before configuring a formatter, ensure you have:- A working sheet configuration with at least one column defined
- Access to edit the YAML configuration (see Download Configuration as YAML)
- Familiarity with the properties available on your entity types
Define a Formatter
Formatters live in theformatters section at the root level of your sheet configuration. Each formatter is a named key containing an array of rules. Each rule pairs an expression (a condition) with a style (the visual treatment to apply when the condition is true).
Step 1. Open your sheet configuration YAML and add a formatters section:
styles section:
boldTitleStyle to illustrate the full define-and-reference flow. Powersheet also ships a built-in boldTitle style (see Predefined Styles); you can reference it directly without a styles entry when its default appearance suits you.
The expression property accepts a JavaScript expression string. When it evaluates to true, the referenced style is applied to the cell. Using the literal 'true' means the style applies unconditionally to every cell in that column.
A formatter style is applied to the entire cell container — both its background (
backgroundColor) and its text (color, fontWeight, textDecoration) — not only to the text content.Unlike other dynamic expressions, a formatter
expression is a bare boolean expression (e.g., value > 100). It does not use the () => prefix; it is evaluated as a direct boolean condition.Apply a Formatter to a Column
Reference the formatter by name in the column’sformatter property:
formatter value must match a key defined in the formatters section exactly. If the name does not match any defined formatter, no styling is applied and no error is raised.
Formatter Evaluation Flow
When a cell renders, Powersheet checks whether the column has aformatter assigned. If so, it evaluates each rule’s expression in the order they appear. The first matching rule determines the style applied.
Use the Expression Context
Inside a formatter expression, you have access to acontext object that provides data about the current cell:
Use dot notation to access entity properties. For example,
context.item.Probability reads the Probability field of the current row’s entity.
Use Multiple Rules
A formatter can contain multiple expression-style pairs. Rules are evaluated top-to-bottom, and the first matching rule determines the applied style. Place the most specific conditions first and use a catch-all'true' rule last for a default style:
Create a Read-Only Formatter
A common pattern combines a formatter with theisReadOnly column property to both visually indicate and enforce that a column cannot be edited:
isReadOnly: true property prevents editing at the column level, while the formatter applies a grey background to visually communicate the read-only state. Note that isReadOnly can also be overridden by document-level permissions or user access control settings.
Define Custom Styles
Styles use CSS-like property names in camelCase. Common properties include:
Powersheet provides a set of predefined color tokens (such as
red100, red700, grey100, orange100, blue100, green100, purple100, teal100, and their dark/light variants) that you can use alongside standard CSS color values.
Complete YAML Example
This example shows a full configuration with two formatters applied to columns in a requirements traceability sheet:Advanced: Conditional Formatting
Use Expression Variables
Theexpression string is evaluated as JavaScript. The variable value represents the current cell value, enabling numeric comparisons and pattern matching:
End your formatter rules with
expression: 'true' as a catch-all. Without a fallback, cells that match no rule receive no formatting.Predefined Styles
Powersheet includes 20 built-in styles you can reference directly without defining them in thestyles section:
You can use predefined style names directly in formatter rules:
Verification
After saving your configuration changes:- Reload the sheet in Polarion with a full browser reload (press
F5, orCtrl+R/Cmd+R) - You should now see cells in the formatted columns displaying the conditional styles you defined
- Verify that cells matching your expression conditions show the correct background color and text styling
- For read-only formatters, confirm that clicking the cell does not enter edit mode and the grey background is visible
formatter value on the column matches a key in the formatters section, and that each style value within the formatter matches a key in the styles section.
See Also
- Apply Column Styles — apply cell, header, and column-group styles, including styling the headers of columns within a group
- Configure a Column Group — visually organize related columns with shared styling
- Configure Read-Only Column — enforce read-only behavior at the column level
- Add a Column — basic column configuration properties
- Create a View — define named view presets with different column visibility
- Keyboard Shortcuts — row grouping, column freezing, and other in-sheet shortcuts
- Sheet Configuration Reference — complete property reference for sheet configuration YAML