TRUECALC
MCP

file:import

Imports a workbook file.

Parameters

NameTypeRequiredDescription
format"json", "csv", "tsv", "xlsx"yes
encoding"text", "base64"noHow data is encoded on the wire. base64 is required for xlsx, binary, and allowed for csv/tsv/json too if the caller's bytes happen to be base64-wrapped UTF-8. Defaults to "text".
datastringyes
sheetNamestring or nullnoBase name for the created sheet. Omitted defaults to "Imported". NOT validated the way sheet:add's name field is.

Returns

NameTypeRequiredDescription
sheetstringyesThe created sheet's final, deduped, sanitized name.
cellsWrittenintegeryesComputed by reading the engine back after the write, never a count of attempted writes, the same discipline sheet:add/sheet:rename/ edit:setCell all already apply, never assume a write landed.

Schema

Request payload, as JSON Schema:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Payload",
  "type": "object",
  "properties": {
    "format": {
      "$ref": "#/$defs/Format"
    },
    "encoding": {
      "$ref": "#/$defs/Encoding",
      "default": "text"
    },
    "data": {
      "type": "string"
    },
    "sheetName": {
      "description": "Base name for the created sheet. Omitted defaults to `\"Imported\"`. NOT validated the way `sheet:add`'s `name` field is.",
      "type": [
        "string",
        "null"
      ],
      "default": null
    }
  },
  "required": [
    "format",
    "data"
  ],
  "$defs": {
    "Format": {
      "type": "string",
      "enum": [
        "json",
        "csv",
        "tsv",
        "xlsx"
      ]
    },
    "Encoding": {
      "description": "How `data` is encoded on the wire. `base64` is required for `xlsx`, binary, and allowed for `csv`/`tsv`/`json` too if the caller's bytes happen to be base64-wrapped UTF-8.",
      "type": "string",
      "enum": [
        "text",
        "base64"
      ]
    }
  }
}

Response payload, as JSON Schema:

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Output",
  "description": "This command only ever creates one.",
  "type": "object",
  "properties": {
    "sheet": {
      "description": "The created sheet's final, deduped, sanitized name.",
      "type": "string"
    },
    "cellsWritten": {
      "description": "Computed by reading the engine back after the write, never a count of attempted writes, the same discipline `sheet:add`/`sheet:rename`/ `edit:setCell` all already apply, never assume a write landed.",
      "type": "integer",
      "format": "uint",
      "minimum": 0
    }
  },
  "required": [
    "sheet",
    "cellsWritten"
  ]
}

On this page