Case

Define a format or content that is inserted into a cell based on a condition. The condition is evaluated against the content of the cell.

When multiple conditionals shall be applied, they must be items in an array.

Example

"case": [
    {
        "if": {
            "value": {
            "greaterThan": 10
            }
        },
        "then": {
            "formatRef": "light-green"
        }
    },
    {
        "if": {...},
        "then": {...},
        "else": {...}
    }
]

Implementations

Cell

Column

Properties

name type description
if object The condition definition object.
if.value object Object holding a condition rule.

Attention: only one property allowed!
if.value.beginsWith string Check if value has substring at the start.
if.value.contains string Check if value has substring anywhere.
if.value.containsAll array Check if all of multiple substrings exist in value.

Array items:
  substring string
if.value.containsAny array Check if any of multiple substrings exists in value.

Array Items:
  substring string
if.value.endsWith string Check if value has substring at the end.
if.value.equalTo number Compare numbers.
string Compare strings. Case-insensitive when comparing strings.
if.value.greaterThan number Check if value is greater than number.
if.value.greaterThanOrEqualTo number Check if value is greater or equal than number.
if.value.lessThan number Check if value is lower than number.
if.value.lessThanOrEqualTo number Check if value is lower than or equal to number.
then object When the condition evaluates true, the object defined here is applied to/inserted into the cell.
then.formatRef object A named format is applied to the cell.

FormatRef link
then.picture object A named format is applied to the cell.

Picture link
then.value string Insert a string value into cell.
number Insert a numeric value into cell.
null Insert nothing/null value into cell.
else object When the condition evaluates false, the object defined here is applied to/inserted into the cell.
else.formatRef object A named format is applied to the cell.

FormatRef link
else.picture object A named format is applied to the cell.

Picture link
else.value string Insert a string value into cell.
number Insert a numeric value into cell.
null Insert nothing/null value into cell.

Example

"case": [
    {
        "if": {
            "value": {
                "endsWith": "€"
            }
        },
        "then": {
            "formatRef": "euro-blue"
        }
    },
    {
        "if": {
            "value": {
                "equalTo": 0
            }
        },
        "then": {
            "value": "",
            "picture": {
                "ref": "zero.png"
            }
        },
        "else": {
            "format": {
                "border": "none"
            }
        }
    },
    {
        "if": {
            "value": {
                "greaterThanOrEqualTo": 5000
            }
        },
        "then": {
            "format": {
                "borderColor": "Green"
            }
        }
    }
]