TRUECALC
MCP

format:setConditionalFormat

Sets the conditional format.

Parameters

NameTypeRequiredDescription
sheetstringyes
range{ from: string; to: string }yesAn inclusive rectangle. from/to may be equal, a single cell.
rule{ kind: "singleCondition", … } or { minColor: string; maxColor: string; kind: "colorScale" } or { kind: "customFormula", … }yesOne conditional-format rule's wire shape.

Returns

NameTypeRequiredDescription
range{ from: string; to: string }yesAn inclusive rectangle. from/to may be equal, a single cell.
idstringyesThe new rule's id.

Schema

Request payload, as JSON Schema:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Payload",
  "type": "object",
  "properties": {
    "sheet": {
      "type": "string"
    },
    "range": {
      "$ref": "#/$defs/CellRange"
    },
    "rule": {
      "$ref": "#/$defs/RuleWire"
    }
  },
  "required": [
    "sheet",
    "range",
    "rule"
  ],
  "$defs": {
    "CellRange": {
      "description": "An inclusive rectangle. `from`/`to` may be equal, a single cell.",
      "type": "object",
      "properties": {
        "from": {
          "description": "Top-left cell, e.g. `\"A1\"`.",
          "type": "string"
        },
        "to": {
          "description": "Bottom-right cell, e.g. `\"B3\"`.",
          "type": "string"
        }
      },
      "required": [
        "from",
        "to"
      ]
    },
    "RuleWire": {
      "description": "One conditional-format rule's wire shape.",
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "operator": {
              "$ref": "#/$defs/OperatorWire"
            },
            "value": {
              "type": "number",
              "format": "double"
            },
            "value2": {
              "type": [
                "number",
                "null"
              ],
              "format": "double"
            },
            "style": {
              "$ref": "#/$defs/StyleWire"
            },
            "kind": {
              "type": "string",
              "const": "singleCondition"
            }
          },
          "required": [
            "kind",
            "operator",
            "value",
            "style"
          ]
        },
        {
          "type": "object",
          "properties": {
            "minColor": {
              "$ref": "#/$defs/HexColor"
            },
            "maxColor": {
              "$ref": "#/$defs/HexColor"
            },
            "kind": {
              "type": "string",
              "const": "colorScale"
            }
          },
          "required": [
            "kind",
            "minColor",
            "maxColor"
          ]
        },
        {
          "type": "object",
          "properties": {
            "formula": {
              "type": "string"
            },
            "style": {
              "$ref": "#/$defs/StyleWire"
            },
            "kind": {
              "type": "string",
              "const": "customFormula"
            }
          },
          "required": [
            "kind",
            "formula",
            "style"
          ]
        }
      ]
    },
    "OperatorWire": {
      "description": "The wire shape of a single-condition rule's numeric comparison operator.",
      "type": "string",
      "enum": [
        "greaterThan",
        "greaterThanOrEqual",
        "lessThan",
        "lessThanOrEqual",
        "equal",
        "notEqual",
        "between",
        "notBetween"
      ]
    },
    "StyleWire": {
      "description": "A conditional-format rule's style, as the wire restricts it.",
      "type": "object",
      "properties": {
        "bold": {
          "type": [
            "boolean",
            "null"
          ]
        },
        "italic": {
          "type": [
            "boolean",
            "null"
          ]
        },
        "underline": {
          "type": [
            "boolean",
            "null"
          ]
        },
        "strike": {
          "type": [
            "boolean",
            "null"
          ]
        },
        "color": {
          "anyOf": [
            {
              "$ref": "#/$defs/HexColor"
            },
            {
              "type": "null"
            }
          ]
        },
        "fill": {
          "anyOf": [
            {
              "$ref": "#/$defs/HexColor"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "additionalProperties": false
    },
    "HexColor": {
      "description": "A strictly-validated `#rgb`/`#rrggbb`/`#rrggbbaa` hex colour.",
      "type": "string"
    }
  }
}

Response payload, as JSON Schema:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Output",
  "type": "object",
  "properties": {
    "range": {
      "$ref": "#/$defs/CellRange"
    },
    "id": {
      "description": "The new rule's id.",
      "type": "string"
    }
  },
  "required": [
    "range",
    "id"
  ],
  "$defs": {
    "CellRange": {
      "description": "An inclusive rectangle. `from`/`to` may be equal, a single cell.",
      "type": "object",
      "properties": {
        "from": {
          "description": "Top-left cell, e.g. `\"A1\"`.",
          "type": "string"
        },
        "to": {
          "description": "Bottom-right cell, e.g. `\"B3\"`.",
          "type": "string"
        }
      },
      "required": [
        "from",
        "to"
      ]
    }
  }
}

On this page