On this page
Sommatic Docs
Open portal

XLSX Text Extraction

Extracts tabular data from Microsoft Excel (.xlsx) workbooks using openpyxl.

View as Markdown
Open in
AI Available ai.xlsx.extract.text Version 1.0.0 Execution: async

Reads a .xlsx workbook with openpyxl and renders every sheet that has data as a Markdown table under a ## Sheet: <name> heading.

Iterates every non-empty sheet in workbook order and renders each as a standalone markdown table, producing a single normalized text output suitable for downstream LLM consumption, vector indexing, or direct classification.

Features:

  • Per-sheet rendering: Each sheet is emitted with its name as a header followed by a markdown table of its used range.
  • Formatted cell values: Applies the workbook's display formats for numbers, dates, and percentages so the extracted text matches what a user sees in Excel.
  • Merged cells and frozen panes: Merged regions are collapsed to their anchor value and annotated; frozen header rows are marked so they survive downstream truncation.
  • Empty sheet detection: Sheets with no data are skipped and reported in the output metadata rather than emitted as empty sections.
  • Metadata: Workbook properties (title, author, creation date) plus per-sheet statistics (rows, columns, used range).

How it works

  1. Resolves the node config: expressions in config keys are evaluated against the run; the incoming item is used as-is.
  2. Reads content_base64 or file_path from the config first, then from the incoming item. If neither is present it returns error.
  3. Opens the workbook in values mode: formula cells give the value cached in the file, not the formula.
  4. For each sheet in workbook order, drops fully empty rows, pads rows to the widest one, uses the first remaining row as the header and escapes | in cells.
  5. Sheets with no data are skipped and only counted in metadata.
  6. If the script fails it returns error with the Python message and stderr. Otherwise empty: true goes out through empty and any other result through extracted.

In a workflow

The node as it appears in a workflow file (draft_nodes[]), and the envelope of a successful run.

{
  "node_id": "node-xlsx-text",
  "label": "Read workbook",
  "operator_slug": "ai.xlsx.extract.text",
  "operator_version": "1.0.0",
  "config": {
    "execution": {
      "timeout_ms": 120000
    }
  }
}

Configuration

This node has no configuration fields.

Its configuration shows the shared execution settings, but this node does not apply retries (retryOnFail, maxTries) yet. continueOnFail is not applied by any node.

Behaviour in the code

What the implementation does with these keys beyond what the schema says.

execution.timeout_ms
Timeout of the Python subprocess. When unset the code uses 120000 ms (the schema shows 300000 as the default).
content_base64 / file_path
Not declared in the config schema, but read from the config before the incoming item. Use them to point at a file with an expression, e.g. {{ $json.attachment.content_base64 }}.

Output ports

extracted default

At least one sheet has data.

Data
{
  "text": "## Sheet: Sales\n\n| Region | Total |\n| --- | --- |\n| North | 1200 |\n| South | 980.5 |",
  "chars": 84,
  "empty": false,
  "method": "openpyxl",
  "metadata": {
    "sheets_total": 2,
    "sheets_with_data": 1,
    "sheet_names": [
      "Sales",
      "Notes"
    ]
  }
}
empty

No sheet has data. Same shape with text: "" and empty: true.

Data
{
  "text": "",
  "chars": 0,
  "empty": true,
  "method": "openpyxl",
  "metadata": {
    "sheets_total": 1,
    "sheets_with_data": 0,
    "sheet_names": [
      "Sheet1"
    ]
  }
}
error

The input is missing or the script fails. data is { error } or { error, stderr }.

Data
{
  "error": "File is not a zip file",
  "stderr": ""
}

In expressions

What a later node can read from this node's output with $("XLSX Text Extraction").item.json.<path> (write your node's label instead of XLSX Text Extraction). Editor marks the paths the workflow editor suggests under Previous Nodes (the output contract); Worker marks the paths the worker really returns through extracted, from the output shown in Ports.

ExpressionEditorWorker
$("XLSX Text Extraction").item.json.textstring= "## Sheet: Sales\n\n| Region | Total |\n| ---…"
$("XLSX Text Extraction").item.json.charsnumber= 84
$("XLSX Text Extraction").item.json.emptyboolean= false
$("XLSX Text Extraction").item.json.methodstring= "openpyxl"
$("XLSX Text Extraction").item.json.metadataobject= {…}
$("XLSX Text Extraction").item.json.metadata.sheets_totalnumberNot suggested by the editor= 2—
$("XLSX Text Extraction").item.json.metadata.sheets_with_datanumberNot suggested by the editor= 1—
$("XLSX Text Extraction").item.json.metadata.sheet_namesarrayNot suggested by the editor= […] (2)—

— Worker: The worker returns it but the editor does not suggest it: write it by hand. Keys inside objects can depend on your data or configuration (for example one key per label).

Errors

Message Port Cause and fix
Either content_base64 or file_path is required. error Neither the config nor the incoming item has content_base64 or file_path. Map the file from the previous node.
Either content_base64 or file_path is required error Raised by the Python script when file_path does not exist on the orchestrator host. Data also carries stderr.
<exception message from the Python library> error The file could not be read as a .xlsx workbook (corrupt, encrypted or another format). data.stderr has the details.
Python timed out after <timeout_ms>ms error The script exceeded execution.timeout_ms. Raise it or process fewer pages.
Python runtime not available (ENOENT) error No Python interpreter is available on the orchestrator host.

Input contract

content_base64 string Optional
file_path string Optional

Output contract

text string Optional
chars number Optional
empty boolean Optional
method string Optional
metadata object Optional

Contracts (JSON Schema)

The definition exactly as the orchestrator declares it. All is the whole *.definition.js; compare it with the sections above to spot differences between the documentation and the schema. Use it to validate a node before you publish.

{
  "slug": "ai.xlsx.extract.text",
  "name": "XLSX Text Extraction",
  "category": "ai",
  "version": "1.0.0",
  "description": "Extracts tabular data from Microsoft Excel (.xlsx) workbooks using openpyxl.\n\n  Iterates every non-empty sheet in workbook order and renders each as a standalone markdown table, producing a single normalized text output suitable for downstream LLM consumption, vector indexing, or direct classification.\n\n  **Features:**\n  - **Per-sheet rendering:** Each sheet is emitted with its name as a header followed by a markdown table of its used range.\n  - **Formatted cell values:** Applies the workbook's display formats for numbers, dates, and percentages so the extracted text matches what a user sees in Excel.\n  - **Merged cells and frozen panes:** Merged regions are collapsed to their anchor value and annotated; frozen header rows are marked so they survive downstream truncation.\n  - **Empty sheet detection:** Sheets with no data are skipped and reported in the output metadata rather than emitted as empty sections.\n  - **Metadata:** Workbook properties (title, author, creation date) plus per-sheet statistics (rows, columns, used range).",
  "capabilities": [
    "xlsx",
    "office",
    "excel",
    "spreadsheet",
    "text-extraction"
  ],
  "config_schema": {
    "type": "object",
    "properties": {
      "execution": {
        "type": "object",
        "title": "Execution Settings",
        "properties": {
          "alwaysOutputData": {
            "type": "boolean",
            "title": "Always Output Data",
            "description": "Always output data, even on error (if configured).",
            "default": false
          },
          "retryOnFail": {
            "type": "boolean",
            "title": "Retry On Fail",
            "description": "Retry the execution if it fails.",
            "default": false
          },
          "maxTries": {
            "type": "integer",
            "title": "Max Retries",
            "description": "Number of retries.",
            "default": 3,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "waitBetweenTries": {
            "type": "integer",
            "title": "Wait Between Retries (ms)",
            "default": 1000,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "continueOnFail": {
            "type": "boolean",
            "title": "Continue On Fail",
            "description": "Do not crash workflow on error.",
            "default": false
          },
          "timeout_ms": {
            "type": "integer",
            "title": "Timeout (ms)",
            "description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
            "default": 300000
          }
        }
      }
    }
  },
  "input_contract_schema": {
    "type": "object",
    "properties": {
      "content_base64": {
        "type": "string"
      },
      "file_path": {
        "type": "string"
      }
    }
  },
  "output_contract_schema": {
    "type": "object",
    "properties": {
      "text": {
        "type": "string"
      },
      "chars": {
        "type": "number"
      },
      "empty": {
        "type": "boolean"
      },
      "method": {
        "type": "string"
      },
      "metadata": {
        "type": "object"
      }
    }
  },
  "ports": [
    {
      "port_id": "extracted",
      "label": "Extracted",
      "is_default": true,
      "supports_condition": true
    },
    {
      "port_id": "empty",
      "label": "Empty",
      "is_default": false,
      "supports_condition": true
    },
    {
      "port_id": "error",
      "label": "Error",
      "is_default": false,
      "supports_condition": false
    }
  ],
  "execution_mode": "async",
  "tags": [
    "ai",
    "xlsx",
    "office",
    "excel",
    "spreadsheet",
    "text"
  ],
  "is_stateful": false,
  "publisher": {
    "identity": "org_sommatic_ai",
    "profile": {
      "name": "Sommatic AI",
      "verified": true,
      "url": "https://me.veripass.com/sommatic",
      "logo_url": null
    }
  }
}

Execution

Execution
async
Stateful
No
Retries (retryOnFail)
No
Capabilities
xlsxofficeexcelspreadsheettext-extraction
Tags
aixlsxofficeexcelspreadsheettext

Notes and limits

  • Cell values are written as plain Python strings, not with Excel display formats: a date comes out as 2026-01-15 00:00:00 and 25% as 0.25.
  • Formulas are never computed. A workbook saved without cached values (for example, generated by a script) yields empty cells for its formulas.
  • Not implemented, although the description mentions them: merged-cell and frozen-pane annotations, and workbook properties (title, author, creation date).
  • Only .xlsx is supported; legacy .xls files fail.
  • file_path is a path on the orchestrator host. content_base64 wins when both are present.
  • The extraction runs in a Python subprocess. On first use the orchestrator creates a virtual environment and installs the pinned requirements, which can take minutes; later runs reuse it.
  • The Python result is limited to 50 MB of output; above it the node leaves through error.
  • The engine does not apply execution.retryOnFail, maxTries, waitBetweenTries or continueOnFail to this node. Handle failures by wiring the error port.

Reviewed against the orchestrator code · 31e874b · 2026-11-26

Install agent tools

Give your coding agent the official Sommatic AI docs: skills, the docs MCP server and Markdown pages, so it never has to scrape the site.

Skills only. They do not update by themselves; run it again to refresh.

npx skills add https://docs.sommatic.ai
How agents read these docs