TRUECALC
MCP

read:getValues

Gets the values.

Parameters

NameTypeRequiredDescription
sheetstringyesThe sheet name.
range{ from: string; to: string }yesThe inclusive rectangle to read.
layers"values", "formulas", "both"noWhich layer(s) to read. Google Sheets' own getValues() default.
encoding"rows", "a1"noHow to shape values/formulas in the response. Defaults to "rows".

Returns

NameTypeRequiredDescription
range{ from: string; to: string }yesThe rectangle this call answered for, completely.
rowsintegeryesrange's row count.
colsintegeryesrange's column count.
encoding"rows", "a1"yesEchoes the requested shape, so a caller reading values/formulas out of band still knows how to interpret it.
nonEmptyarray of stringyesEvery address in range whose display text is non-empty or which holds a formula, in row-major, reading order, the sparse summary a caller wants before paying to decode a mostly-empty rectangle.
valuesanynoPresent iff layers was values/both. Row-major Vec<Vec<String>> or an A1-keyed map, depending on encoding.
formulasanynoPresent iff layers was formulas/both. Same shape rule as values, an empty string where a cell holds no formula.

Schema

Request payload, as JSON Schema:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Payload",
  "type": "object",
  "properties": {
    "sheet": {
      "description": "The sheet name.",
      "type": "string"
    },
    "range": {
      "description": "The inclusive rectangle to read.",
      "$ref": "#/$defs/CellRange"
    },
    "layers": {
      "$ref": "#/$defs/Layers",
      "default": "values"
    },
    "encoding": {
      "$ref": "#/$defs/Encoding",
      "default": "rows"
    }
  },
  "required": [
    "sheet",
    "range"
  ],
  "$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"
      ]
    },
    "Layers": {
      "description": "Which layer(s) to read. Google Sheets' own `getValues()` default.",
      "type": "string",
      "enum": [
        "values",
        "formulas",
        "both"
      ]
    },
    "Encoding": {
      "description": "How to shape `values`/`formulas` in the response.",
      "oneOf": [
        {
          "description": "Row-major arrays: `values[i][j]` is the cell at `range`'s `i`-th row, `j`-th column.",
          "type": "string",
          "const": "rows"
        },
        {
          "description": "A map keyed by plain A1 form, `\"A1\"`, one entry per address in `range`.",
          "type": "string",
          "const": "a1"
        }
      ]
    }
  }
}

Response payload, as JSON Schema:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Output",
  "type": "object",
  "properties": {
    "range": {
      "description": "The rectangle this call answered for, completely.",
      "$ref": "#/$defs/CellRange"
    },
    "rows": {
      "description": "`range`'s row count.",
      "type": "integer",
      "format": "uint32",
      "minimum": 0
    },
    "cols": {
      "description": "`range`'s column count.",
      "type": "integer",
      "format": "uint32",
      "minimum": 0
    },
    "encoding": {
      "description": "Echoes the requested shape, so a caller reading `values`/`formulas` out of band still knows how to interpret it.",
      "$ref": "#/$defs/Encoding"
    },
    "nonEmpty": {
      "description": "Every address in `range` whose display text is non-empty or which holds a formula, in row-major, reading order, the sparse summary a caller wants before paying to decode a mostly-empty rectangle.",
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "values": {
      "description": "Present iff `layers` was `values`/`both`. Row-major `Vec<Vec<String>>` or an A1-keyed map, depending on `encoding`."
    },
    "formulas": {
      "description": "Present iff `layers` was `formulas`/`both`. Same shape rule as `values`, an empty string where a cell holds no formula."
    }
  },
  "required": [
    "range",
    "rows",
    "cols",
    "encoding",
    "nonEmpty"
  ],
  "$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"
      ]
    },
    "Encoding": {
      "description": "How to shape `values`/`formulas` in the response.",
      "oneOf": [
        {
          "description": "Row-major arrays: `values[i][j]` is the cell at `range`'s `i`-th row, `j`-th column.",
          "type": "string",
          "const": "rows"
        },
        {
          "description": "A map keyed by plain A1 form, `\"A1\"`, one entry per address in `range`.",
          "type": "string",
          "const": "a1"
        }
      ]
    }
  }
}

On this page