Iteration Layer

Generate Formatted Excel Spreadsheets in n8n

6 min read Sheet Generation

n8n Can Read Spreadsheets but Can’t Generate Them

n8n has solid spreadsheet reading support. The Spreadsheet File node parses XLSX and CSV. The Google Sheets node reads and writes rows. But generating a standalone XLSX file — with formatted headers, currency columns, multiple sheets, and formulas — does not have a native answer.

The workarounds are all painful. You can use a Function node with ExcelJS, but you are writing JavaScript to build a spreadsheet cell by cell. You lose the visual workflow benefit of n8n entirely. You can export from Google Sheets, but that means creating a temporary sheet, writing data, formatting it through the Google Sheets API (which has a separate formatting endpoint from the data endpoint), exporting to XLSX, and cleaning up the temporary file. That is five nodes for one spreadsheet.

Some teams use a Puppeteer node to render an HTML table and “print” it to XLSX. This works about as well as you would expect — the formatting is approximate, formulas are impossible, and multiple sheets are out of the question.

Define the Spreadsheet, Get an XLSX

Iteration Layer Sheet Generation takes a JSON definition and returns a binary XLSX file. You define sheets, columns, rows, cell formatting, and formulas. The API handles rendering. No code, no temporary files, no export chain.

The definition is declarative. You describe what the spreadsheet should look like — column widths, header styles, cell formats, formulas — and the API builds it. Currency formatting, percentage formatting, date formatting, bold headers, merged cells, and Excel formulas all work through the JSON definition.

The output is a standard XLSX file that opens in Excel, Google Sheets, LibreOffice, or any spreadsheet application. Or request CSV or Markdown format if you need a simpler output.

The Workflow: Database Query to Email Report

Here is what we are building in n8n: a weekly automated pipeline that queries sales data from a database, generates a formatted Excel report with multiple sheets, and emails it to the team. Four nodes. No Function nodes. No Google Sheets intermediary.

Step 1: Schedule Trigger

Open the n8n canvas and add a new node. Search for “Schedule Trigger” and add it.

In the node settings, set the Trigger Interval to “Weeks” and pick the day and time for your report — Monday at 8:00 AM is a common choice for weekly sales summaries. This fires the workflow automatically on schedule.

Step 2: Postgres Node (Query Sales Data)

Add a Postgres node (or MySQL, MSSQL, or any database node that fits your stack). Configure your database credentials and enter the query:

SELECT
  product_name,
  region,
  units_sold,
  unit_price,
  units_sold * unit_price AS revenue,
  tax_rate
FROM sales
WHERE sale_date >= NOW() - INTERVAL '7 days'
ORDER BY revenue DESC

The node returns an array of items, one per row. Each item has the column values as properties. This is the data that will populate the spreadsheet.

Step 3: Iteration Layer (Sheet Generation)

Add an Iteration Layer node. In the Resource dropdown, select Sheet Generation. Set the Format to xlsx.

In the Sheets JSON field, define the spreadsheet structure. Here is a concrete example with two sheets — a sales detail sheet and a summary sheet:

{
  "sheets": [
    {
      "name": "Sales Detail",
      "columns": [
        { "name": "Product", "width": 30 },
        { "name": "Region", "width": 15 },
        { "name": "Units Sold", "width": 12 },
        { "name": "Unit Price", "width": 14 },
        { "name": "Revenue", "width": 16 },
        { "name": "Tax Rate", "width": 10 }
      ],
      "header_style": {
        "bold": true,
        "background_color": "#1a1a2e",
        "font_color": "#ffffff"
      },
      "rows": [
        {
          "values": [
            { "value": "Enterprise Platform License" },
            { "value": "EMEA" },
            { "value": 142 },
            { "value": 299.00, "format": "currency", "currency": "EUR" },
            { "value": 42458.00, "format": "currency", "currency": "EUR" },
            { "value": 0.19, "format": "percentage" }
          ]
        },
        {
          "values": [
            { "value": "API Access — Pro Tier" },
            { "value": "Americas" },
            { "value": 89 },
            { "value": 149.00, "format": "currency", "currency": "USD" },
            { "value": 13261.00, "format": "currency", "currency": "USD" },
            { "value": 0.07, "format": "percentage" }
          ]
        }
      ]
    },
    {
      "name": "Summary",
      "columns": [
        { "name": "Metric", "width": 25 },
        { "name": "Value", "width": 20 }
      ],
      "header_style": {
        "bold": true,
        "background_color": "#1a1a2e",
        "font_color": "#ffffff"
      },
      "rows": [
        {
          "values": [
            { "value": "Total Revenue" },
            { "value": 55719.00, "format": "currency", "currency": "EUR" }
          ]
        },
        {
          "values": [
            { "value": "Total Units Sold" },
            { "value": 231 }
          ]
        },
        {
          "values": [
            { "value": "Average Unit Price" },
            { "value": "=55719/231", "format": "formula" }
          ]
        }
      ]
    }
  ]
}

In practice, you would build the rows array dynamically using n8n expressions that reference the Postgres node output. The static example above shows the structure — column definitions with widths, header styling, and cell-level formatting for currency, percentages, and formulas.

Key formatting options:

  • Currency: Set "format": "currency" and "currency": "EUR" on a cell value. The XLSX renders with the correct currency symbol and two decimal places.
  • Percentage: Set "format": "percentage". The value 0.19 renders as 19%.
  • Formulas: Set "format": "formula" and pass the Excel formula as the value string. Standard Excel formula syntax works — SUM, AVERAGE, VLOOKUP, cell references.
  • Header styling: The header_style object applies to the first row of each sheet. Bold text, background colors, and font colors.
  • Multiple sheets: Each object in the sheets array becomes a separate sheet tab in the XLSX file.

The node returns the generated XLSX as n8n binary data, ready to attach to an email, upload to a file storage service, or pass to another node.

Step 4: Send Email Node

Add a Send Email node (or Gmail, Outlook, or any email node). Configure your SMTP credentials or OAuth connection.

Set the To field to the distribution list for the report. Add a subject line like Weekly Sales Report — {{ $now.format('yyyy-MM-dd') }}. In the Attachments section, select the binary data output from the Iteration Layer node. The XLSX file attaches automatically.

The recipients get a formatted Excel file in their inbox every Monday morning. No Google Sheets link to lose access to. No CSV that loses all formatting on open. A proper XLSX with styled headers, currency formatting, and a summary sheet.

Beyond the Weekly Report

The same Sheet Generation resource handles any spreadsheet need in your workflows:

  • Invoice line item exports: Extract data from invoices using Document Extraction, then generate a formatted XLSX with each invoice on its own sheet. Finance teams get a file they can open in Excel immediately — no CSV import step, no column width adjustments.
  • Inventory reports: Query product stock levels on a schedule, generate an XLSX with conditional formatting highlights for low-stock items, and upload to a shared drive.
  • Client deliverables: Pull analytics data from your application’s API, generate a branded report with your client’s data on separate sheets, and email it automatically. The formatting stays consistent across every client.
  • Data migration exports: When moving data between systems, generate an XLSX with the exact column structure the target system expects. The import template matches on the first try.

CSV and Markdown Alternatives

Not every use case needs a full XLSX. Set the Format to csv for a simple comma-separated output, or markdown for a Markdown table. The same sheet definition works for all three formats — change one parameter and the output format changes.

CSV is useful when the downstream system only accepts plain text. Markdown is useful when the spreadsheet data feeds into documentation, a chat message, or a Markdown-based CMS.

Get Started

Install the Iteration Layer community node from the n8n UI — search for n8n-nodes-iterationlayer under Settings > Community Nodes. The Sheet Generation docs cover all formatting options, formula syntax, and multi-sheet configuration. The n8n integration docs walk through every resource and parameter.

Start with a simple single-sheet report. Define your columns, add a few rows with formatting, and check the output in Excel or Google Sheets. Once the structure looks right, wire it up to your data source and schedule trigger. Sign up to get your API key.

Build your first workflow in minutes

Chain our APIs together and ship a complete pipeline before lunch. Free trial credits included — no credit card required.