JSON to Excel

Convert JSON data to Excel spreadsheets with single or multiple sheets.

Endpoint

POST https://www.acrewity.com/api/services/execute

Authentication

Include your API key in the Authorization header:

Authorization: Bearer YOUR_API_KEY

n8n Integration

This service is also available via our n8n community node: @acrewity/n8n-nodes-acrewity

Operations

Create Excel (Single Sheet)

Create an Excel file from an array of objects.

Operation ID: create_excel

Parameters

Parameter Type Required Default Description
data array Yes - Array of objects to convert to Excel rows
sheetName string No Sheet1 Name of the worksheet
headers boolean No true Include headers row from object keys
headerStyle object No - Style for header row (see Cell Styling)
columnStyles object No - Styles by column header name (see Cell Styling)
rowStyles object No - Styles by row number (see Cell Styling)

Example Request

Team Members Export:

{
  "service": "json-to-excel",
  "operation": "create_excel",
  "parameters": {
    "data": [
      { "name": "John Smith", "email": "john@example.com", "role": "Developer", "joined": "2024-01-15" },
      { "name": "Jane Doe", "email": "jane@example.com", "role": "Designer", "joined": "2024-02-20" },
      { "name": "Bob Wilson", "email": "bob@example.com", "role": "Manager", "joined": "2023-11-01" }
    ],
    "sheetName": "Team Members",
    "headers": true
  }
}

With Styling:

{
  "service": "json-to-excel",
  "operation": "create_excel",
  "parameters": {
    "data": [
      { "name": "John Smith", "email": "john@example.com", "role": "Developer" },
      { "name": "Jane Doe", "email": "jane@example.com", "role": "Designer" }
    ],
    "sheetName": "Team",
    "headerStyle": {
      "bold": true,
      "fill": "#4472C4",
      "fontColor": "#FFFFFF",
      "freeze": true
    },
    "columnStyles": {
      "name": { "width": 25 },
      "email": { "width": 30 }
    }
  }
}

Example Response

{
  "success": true,
  "result": {
    "data": {
      "filename": "excel-1735567890123.xlsx",
      "contentType": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
      "size": 4521,
      "content": "UEsDBBQAAAAIAHxLd1kAAAAA...",
      "downloadUrl": "/api/downloads/excel-1735567890123.xlsx",
      "downloadable": true,
      "metadata": {
        "rows": 4,
        "columns": 4,
        "sheetName": "Team Members",
        "format": "xlsx",
        "sourceFormat": "array_of_objects",
        "actualSize": 4521
      }
    }
  },
  "credits_used": 1
}

Create Multi-Sheet Excel

Create an Excel file with multiple worksheets. Supports multiple input formats.

Operation ID: create_multi_sheet

Parameters

Parameter Type Required Default Description
sheets object Yes - Object with sheet names as keys (see formats below)
headers boolean No true Include headers row
useCells boolean No false Use raw cell data for exact positioning
preserveFormulas boolean No false Preserve Excel formulas when using useCells: true
fileName string No export.xlsx Name of the output file

Sheet Data Formats

The create_multi_sheet operation accepts several input formats for sheet data. Choose the format that best fits your use case.

Format 1: Simple Array of Objects (Recommended for new data)

The simplest format - just provide arrays of objects. Headers are automatically extracted from object keys.

{
  "service": "json-to-excel",
  "operation": "create_multi_sheet",
  "parameters": {
    "sheets": {
      "Sales": [
        { "product": "Widget Pro", "quantity": 150, "revenue": 4500 },
        { "product": "Widget Basic", "quantity": 320, "revenue": 3200 }
      ],
      "Inventory": [
        { "item": "Widget Pro", "stock": 500, "warehouse": "A1" },
        { "item": "Widget Basic", "stock": 1200, "warehouse": "B2" }
      ]
    }
  }
}

Format 2: Direct rows and headers (Recommended for programmatic data)

Explicitly specify headers and row data. This is common when building sheets programmatically or from n8n workflows.

{
  "service": "json-to-excel",
  "operation": "create_multi_sheet",
  "parameters": {
    "sheets": {
      "Products": {
        "headers": ["SKU", "Name", "Price", "Stock"],
        "rows": [
          { "SKU": "WP-001", "Name": "Widget Pro", "Price": 29.99, "Stock": 100 },
          { "SKU": "WB-001", "Name": "Widget Basic", "Price": 19.99, "Stock": 250 }
        ]
      },
      "Categories": {
        "headers": ["ID", "Category", "Description"],
        "rows": [
          { "ID": 1, "Category": "Electronics", "Description": "Electronic devices" },
          { "ID": 2, "Category": "Office", "Description": "Office supplies" }
        ]
      }
    }
  }
}

Format 3: detectedTable with range (Round-trip from excel-to-json)

Use this format when working with data from the excel-to-json service. The range parameter controls where the table is positioned in the sheet.

{
  "service": "json-to-excel",
  "operation": "create_multi_sheet",
  "parameters": {
    "sheets": {
      "Sheet1": {
        "detectedTable": {
          "headers": ["Name", "Age", "City"],
          "rows": [
            { "Name": "John", "Age": 30, "City": "NYC" },
            { "Name": "Jane", "Age": 25, "City": "LA" }
          ],
          "range": "A1"
        }
      }
    }
  }
}

The range Parameter

The range parameter in detectedTable specifies the starting cell for the table:

Range Value Result
"A1" Table starts at cell A1 (row 1, column A)
"B5" Table starts at cell B5 (row 5, column B)
"C10" Table starts at cell C10 (row 10, column C)
Not specified Defaults to A1

Example: Positioning table below metadata

If your original Excel had metadata in rows 1-4 and the data table starting at row 6:

{
  "service": "json-to-excel",
  "operation": "create_multi_sheet",
  "parameters": {
    "sheets": {
      "Report": {
        "cells": {
          "A1": { "value": "Monthly Report" },
          "A2": { "value": "Generated: 2024-01-15" },
          "A3": { "value": "" }
        },
        "detectedTable": {
          "headers": ["Product", "Sales", "Revenue"],
          "rows": [
            { "Product": "Widget", "Sales": 100, "Revenue": 5000 }
          ],
          "range": "A5"
        }
      }
    }
  }
}

Format 4: cells for Exact Positioning (Preserves layout and formulas)

Use useCells: true for exact cell-by-cell control. Perfect for spreadsheets with complex layouts, merged cells, or formulas.

{
  "service": "json-to-excel",
  "operation": "create_multi_sheet",
  "parameters": {
    "useCells": true,
    "preserveFormulas": true,
    "sheets": {
      "Budget": {
        "cells": {
          "A1": { "value": "Item" },
          "B1": { "value": "Amount" },
          "A2": { "value": "Rent" },
          "B2": { "value": 1500 },
          "A3": { "value": "Utilities" },
          "B3": { "value": 200 },
          "A4": { "value": "Total" },
          "B4": { "value": 1700, "formula": "SUM(B2:B3)" }
        }
      }
    }
  }
}

Format 5: Combined cells + detectedTable

You can combine metadata cells with a data table. The table will be positioned after the cells.

{
  "service": "json-to-excel",
  "operation": "create_multi_sheet",
  "parameters": {
    "sheets": {
      "Invoice": {
        "cells": {
          "A1": { "value": "INVOICE #12345" },
          "A2": { "value": "Date: 2024-01-15" },
          "A3": { "value": "Customer: Acme Corp" }
        },
        "detectedTable": {
          "headers": ["Item", "Qty", "Price", "Total"],
          "rows": [
            { "Item": "Widget", "Qty": 10, "Price": 25.00, "Total": 250.00 },
            { "Item": "Gadget", "Qty": 5, "Price": 50.00, "Total": 250.00 }
          ],
          "range": "A5"
        }
      }
    }
  }
}

Example Response

{
  "success": true,
  "result": {
    "data": {
      "filename": "export.xlsx",
      "contentType": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
      "size": 8932,
      "content": "UEsDBBQAAAAIAHxLd1kAAAAA...",
      "downloadUrl": "/api/downloads/excel-abc123-def456.xlsx",
      "downloadable": true,
      "sheetCount": 3,
      "sheetNames": ["Sales", "Inventory", "Employees"],
      "sourceFormat": "excel-to-json"
    }
  },
  "credits_used": 1
}

Round-Trip Workflow: Excel -> JSON -> Excel

You can read an Excel file with multiple sheets using excel-to-json, modify the data, and write it back:

Step 1: Read Excel with excel-to-json

{
  "service": "excel-to-json",
  "operation": "read_excel",
  "parameters": {
    "file": "data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,UEsDBBQ..."
  }
}

Step 2: The response includes detectedTable with headers, rows, and range

{
  "success": true,
  "data": {
    "sheets": {
      "Sheet1": {
        "cells": { ... },
        "detectedTable": {
          "headers": ["Name", "Age"],
          "rows": [{ "Name": "John", "Age": 30 }],
          "range": "A1"
        }
      }
    }
  }
}

Step 3: Modify the data and write back

{
  "service": "json-to-excel",
  "operation": "create_multi_sheet",
  "parameters": {
    "sheets": {
      "Sheet1": {
        "detectedTable": {
          "headers": ["Name", "Age"],
          "rows": [
            { "Name": "John", "Age": 30 },
            { "Name": "Jane", "Age": 25 }
          ],
          "range": "A1"
        }
      }
    }
  }
}

Quick Reference: Which Format to Use?

Use Case Recommended Format
Creating new data from scratch Format 1 (Simple arrays)
Building sheets programmatically Format 2 (rows + headers)
Round-trip from excel-to-json Format 3 (detectedTable with range)
Preserving exact cell layout Format 4 (cells)
Metadata header + data table Format 5 (Combined cells + detectedTable)

Cell Styling

Add professional formatting to your Excel exports with cell-level styles, column/row defaults, and table-level styling.

Style Properties Reference

Property Type Values Description
bold boolean true/false Bold font
italic boolean true/false Italic font
fontSize number 8-72 Font size in points
fontColor string hex (#RRGGBB) Font color
fill string hex (#RRGGBB) Background fill color
align string left, center, right Horizontal alignment
valign string top, middle, bottom Vertical alignment
wrap boolean true/false Wrap text in cell
width number 1-255 Column width (for columnStyles)
height number 1-409 Row height (for rowStyles)
border string none, thin, medium, thick Cell border style
numberFormat string @, 0.00, #,##0, yyyy-mm-dd Excel number format
freeze boolean true/false Freeze panes at header row (headerStyle only)

Cell-Level Styles

Apply styles to individual cells using the style property:

{
  "service": "json-to-excel",
  "operation": "create_multi_sheet",
  "parameters": {
    "useCells": true,
    "sheets": {
      "Report": {
        "cells": {
          "A1": {
            "value": "Sales Report",
            "style": {
              "bold": true,
              "fontSize": 16,
              "fill": "#4472C4",
              "fontColor": "#FFFFFF",
              "align": "center"
            }
          },
          "A2": {
            "value": "Q4 2024",
            "style": { "italic": true, "fontSize": 12 }
          },
          "B5": {
            "value": 15000,
            "style": { "numberFormat": "#,##0.00", "bold": true }
          }
        }
      }
    }
  }
}

Column and Row Styles

Apply bulk formatting with columnStyles and rowStyles at the sheet level:

{
  "service": "json-to-excel",
  "operation": "create_multi_sheet",
  "parameters": {
    "sheets": {
      "Data": {
        "columnStyles": {
          "A": { "width": 20 },
          "B": { "width": 40, "wrap": true },
          "C:E": { "width": 15, "align": "center" },
          "F:H": { "wrap": true, "width": 30 }
        },
        "rowStyles": {
          "1": { "height": 25, "bold": true, "fill": "#D9E2F3" }
        },
        "headers": ["ID", "Description", "Price", "Qty", "Total", "Notes", "Category", "Status"],
        "rows": [
          { "ID": 1, "Description": "Widget Pro", "Price": 29.99, "Qty": 100, "Total": 2999, "Notes": "Best seller", "Category": "Electronics", "Status": "Active" }
        ]
      }
    }
  }
}

Column Range Notation: Use "G:I" to apply the same style to columns G, H, and I.

Table-Level Styles (headerStyle & columnStyles)

Apply styles to the header row and specific columns by header name using detectedTable:

{
  "service": "json-to-excel",
  "operation": "create_multi_sheet",
  "parameters": {
    "sheets": {
      "BOM": {
        "cells": {
          "A1": { "value": "Bill of Materials", "style": { "bold": true, "fontSize": 16 } }
        },
        "detectedTable": {
          "headers": ["Part Number", "Description", "Manufacturer", "MPN", "Qty"],
          "rows": [
            { "Part Number": "R001", "Description": "10k Resistor", "Manufacturer": "Yageo Corporation International", "MPN": "RC0805FR-0710KL", "Qty": 100 },
            { "Part Number": "C001", "Description": "100nF Capacitor", "Manufacturer": "Samsung Electro-Mechanics", "MPN": "CL21B104KBCNNNC", "Qty": 50 }
          ],
          "range": "A4",
          "headerStyle": {
            "bold": true,
            "fill": "#4472C4",
            "fontColor": "#FFFFFF",
            "freeze": true
          },
          "columnStyles": {
            "Description": { "wrap": true, "width": 40 },
            "Manufacturer": { "wrap": true, "width": 35 },
            "MPN": { "wrap": true, "width": 25 }
          }
        }
      }
    }
  }
}

Key Features:

Complete Styled Example

{
  "service": "json-to-excel",
  "operation": "create_multi_sheet",
  "parameters": {
    "sheets": {
      "Invoice": {
        "cells": {
          "A1": { "value": "INVOICE", "style": { "bold": true, "fontSize": 24, "fill": "#1F4E79", "fontColor": "#FFFFFF" } },
          "A2": { "value": "Invoice #: INV-2024-001", "style": { "fontSize": 11 } },
          "A3": { "value": "Date: January 15, 2024", "style": { "fontSize": 11 } },
          "D1": { "value": "Acme Corp", "style": { "bold": true, "fontSize": 14, "align": "right" } },
          "D2": { "value": "123 Business St", "style": { "align": "right" } }
        },
        "detectedTable": {
          "headers": ["Item", "Description", "Qty", "Unit Price", "Total"],
          "rows": [
            { "Item": "WP-001", "Description": "Widget Pro", "Qty": 10, "Unit Price": 29.99, "Total": 299.90 },
            { "Item": "GB-001", "Description": "Gadget Basic with extended warranty and support package", "Qty": 5, "Unit Price": 49.99, "Total": 249.95 }
          ],
          "range": "A6",
          "headerStyle": {
            "bold": true,
            "fill": "#4472C4",
            "fontColor": "#FFFFFF",
            "align": "center"
          },
          "columnStyles": {
            "Description": { "wrap": true, "width": 45 },
            "Unit Price": { "numberFormat": "$#,##0.00", "align": "right" },
            "Total": { "numberFormat": "$#,##0.00", "bold": true, "align": "right" }
          }
        },
        "rowStyles": {
          "1": { "height": 30 }
        }
      }
    }
  }
}

More Examples

See Data Transformation Examples for complete workflow examples including report downloads, bulk imports, and multi-sheet workbooks.