Sheet kit command

conditionalFormat.apply

Conditional Formatting

Adds a conditional formatting rule to a range (cell value with an operator, formula, text, duplicates, top/bottom, dates, data bar, colour scale, icon set) with its format; the standard names and defaults (icon sets cut at percent of the min–max span).

Kit
Sheet 0.1.0 (.xlsx (and opens .xlsm, .xls, .xltx, .csv, .ods, .xlsb))
Changes the document
yes

Parameters

Parameters of conditionalFormat.apply
NameTypeRequiredDescription
rangestringnocells in A1 notation such as B2 or B2:D10, optionally with a sheet (Sheet2!A1); default: the selection
ruleobjectnothe rule; it refuses keys its type does not read. Newer rules take precedence (their fill wins over an older colour scale's, and the other way round).

Call through sheet_run

text
sheet_run {
  "path": "<file>.xlsx",
  "steps": [{ "command": "conditionalFormat.apply" }]
}

The required parameters, with placeholders for their types: not a tested example. Optional: range, rule. sheet_run answers the step’s result in completed[i].result.

Result

The kit gives no result schema for this command.

Parameter schema

json
{
  "additionalProperties": false,
  "properties": {
    "range": {
      "description": "cells in A1 notation such as B2 or B2:D10, optionally with a sheet (Sheet2!A1); default: the selection",
      "type": "string"
    },
    "rule": {
      "additionalProperties": false,
      "description": "the rule; it refuses keys its type does not read. Newer rules take precedence (their fill wins over an older colour scale's, and the other way round).",
      "properties": {
        "below": {
          "description": "aboveAverage: below the average instead",
          "type": "boolean"
        },
        "bottom": {
          "description": "top10: the lowest instead of the highest",
          "type": "boolean"
        },
        "color": {
          "description": "dataBar: the bar's hex colour",
          "type": "string"
        },
        "colors": {
          "description": "colorScale: two or three hex colours, lowest to highest (the middle at the 50th percentile)",
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "formula": {
          "description": "expression: a formula true for the cells to format, written for the range's first cell (=$B2>100)",
          "type": "string"
        },
        "gradient": {
          "description": "dataBar: fade the bar (default true)",
          "type": "boolean"
        },
        "max": {
          "description": "dataBar: the longest bar's value, as min; default: the highest value"
        },
        "min": {
          "description": "dataBar: the shortest bar's value: a number or {type: number|percent|percentile|formula|min, value}; default: the lowest value"
        },
        "operator": {
          "description": "cellIs: how the cell compares with value (and value2 for between); default: greaterThan",
          "enum": [
            "greaterThan",
            "lessThan",
            "greaterThanOrEqual",
            "lessThanOrEqual",
            "equal",
            "notEqual",
            "between",
            "notBetween"
          ],
          "type": "string"
        },
        "percent": {
          "description": "top10: rank is a percent",
          "type": "boolean"
        },
        "period": {
          "description": "timePeriod: the dates to format",
          "enum": [
            "yesterday",
            "today",
            "tomorrow",
            "last7Days",
            "lastWeek",
            "thisWeek",
            "nextWeek",
            "lastMonth",
            "thisMonth",
            "nextMonth"
          ],
          "type": "string"
        },
        "preset": {
          "description": "a ready format instead of style; default lightRedFillDarkRedText",
          "enum": [
            "lightRedFillDarkRedText",
            "lightRedFill",
            "redText",
            "yellowFill",
            "yellowFillDarkYellowText",
            "greenFill",
            "greenFillDarkGreenText",
            "redBorder"
          ],
          "type": "string"
        },
        "rank": {
          "description": "top10: how many (or what percent with percent: true); default 10",
          "type": "integer"
        },
        "reverse": {
          "description": "iconSet: the icons in reverse order",
          "type": "boolean"
        },
        "set": {
          "description": "iconSet: the icons (the digit is how many); default 3TrafficLights1",
          "enum": [
            "3Arrows",
            "3ArrowsGray",
            "3Flags",
            "3TrafficLights1",
            "3TrafficLights2",
            "3Signs",
            "3Symbols",
            "3Symbols2",
            "3Stars",
            "3Triangles",
            "4Arrows",
            "4ArrowsGray",
            "4RedToBlack",
            "4Rating",
            "4TrafficLights",
            "5Arrows",
            "5ArrowsGray",
            "5Rating",
            "5Quarters",
            "5Boxes"
          ],
          "type": "string"
        },
        "showValue": {
          "description": "iconSet, dataBar: false shows the icon or bar alone",
          "type": "boolean"
        },
        "style": {
          "description": "the format of a formatted rule (not colorScale, dataBar, iconSet): {fill: \"#RRGGBB\", font: {color: \"#RRGGBB\", bold, italic, strike, underline}, borders: {top|bottom|left|right: {style: Thin, color: \"#RRGGBB\"}}}"
        },
        "text": {
          "description": "containsText, notContainsText, beginsWith, endsWith: the text (any case)",
          "type": "string"
        },
        "thresholds": {
          "description": "iconSet: the boundaries between icons, ascending, one fewer than the icons; each a number (percent of the span from the lowest value to the highest) or {type: number|percent|percentile|formula, value}. Default: percent at equal steps (33 and 67 for three icons)",
          "items": {},
          "type": "array"
        },
        "type": {
          "description": "default: cellIs",
          "enum": [
            "cellIs",
            "expression",
            "containsText",
            "notContainsText",
            "beginsWith",
            "endsWith",
            "blanks",
            "noBlanks",
            "errors",
            "noErrors",
            "duplicate",
            "unique",
            "top10",
            "aboveAverage",
            "timePeriod",
            "colorScale",
            "dataBar",
            "iconSet"
          ],
          "type": "string"
        },
        "value": {
          "description": "cellIs: a number, text, or a =formula (relative to the range's first cell)"
        },
        "value2": {
          "description": "cellIs between and notBetween: the other end"
        }
      },
      "type": "object"
    }
  },
  "type": "object"
}

Generated from the command list of @kition/[email protected] and the kit itself (sheet_commands through @kition/[email protected], built from KitionAI/kition-sheet@82f13b2). As data: commands.jsonl.