TRUECALC
MCP

edit:findReplace

Finds and replaces text within a range.

Parameters

NameTypeRequiredDescription
sheetstringyes
range{ from: string; to: string } or nullnoThe scope to search, the whole sheet's occupied footprint when absent.
querystringyes
replacementstringyes
matchCasebooleannoDefaults to false.
useRegexbooleannoDefaults to false.
matchEntireCellbooleannoDefaults to false.
withinFormulasbooleannoDefaults to false.

Returns

NameTypeRequiredDescription
queryCompiledbooleanyesWhether query compiled as a regex, always true when useRegex is false, since the literal form is always regex::escaped before compiling, escaping cannot fail.
matchedintegeryesHow many scope cells' search text matched, counted whether or not the match was eligible to be written back.

Schema

Request payload, as JSON Schema:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Payload",
  "type": "object",
  "properties": {
    "sheet": {
      "type": "string"
    },
    "range": {
      "description": "The scope to search, the whole sheet's occupied footprint when absent.",
      "anyOf": [
        {
          "$ref": "#/$defs/CellRange"
        },
        {
          "type": "null"
        }
      ]
    },
    "query": {
      "type": "string"
    },
    "replacement": {
      "type": "string"
    },
    "matchCase": {
      "type": "boolean",
      "default": false
    },
    "useRegex": {
      "type": "boolean",
      "default": false
    },
    "matchEntireCell": {
      "type": "boolean",
      "default": false
    },
    "withinFormulas": {
      "type": "boolean",
      "default": false
    }
  },
  "required": [
    "sheet",
    "query",
    "replacement"
  ],
  "$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"
      ]
    }
  }
}

Response payload, as JSON Schema:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Output",
  "description": "This command's own extra result fields.",
  "type": "object",
  "properties": {
    "queryCompiled": {
      "description": "Whether `query` compiled as a regex, always `true` when `useRegex` is `false`, since the literal form is always `regex::escape`d before compiling, escaping cannot fail.",
      "type": "boolean"
    },
    "matched": {
      "description": "How many scope cells' search text matched, counted whether or not the match was eligible to be written back.",
      "type": "integer",
      "format": "uint",
      "minimum": 0
    }
  },
  "required": [
    "queryCompiled",
    "matched"
  ]
}

On this page