---
title: "Generate Excel workbook from JSON"
method: POST
path: "/api/excel/generate"
tags: ["Excel"]
---

# Generate Excel workbook from JSON

`POST /api/excel/generate`

## Request

- Base URL: `https://api.dokmatiq.com`
- URL: `https://api.dokmatiq.com/api/excel/generate`
- Auth: API key in header `X-API-Key`

Create a fully styled Excel workbook (.xlsx) from a structured JSON definition. Supports multiple sheets, column definitions, formulas, styling, headers/footers, freeze panes, print areas, merged cells, and more.

## Request body

- ExcelRequest: Request to generate an Excel workbook from structured JSON data
  - `sheets` SheetDefinition[]: List of sheets to create in the workbook
    - `name` string: Sheet tab name
    - `columns` ExcelColumnDef[]: Column definitions with headers, widths, formats, and alignment
      - `index` integer: Column index (0-based). If omitted, columns are created in list order.
      - `header` string: Column header text
      - `width` integer: Column width in characters
      - `format` string: Excel number format for data cells in this column
      - `align` 'LEFT' | 'CENTER' | 'RIGHT': Horizontal alignment for data cells
      - `headerStyle` ExcelCellStyle: Cell styling definition for Excel cells
        - `fontName` string: Font name
        - `fontSize` integer: Font size in points
        - `bold` boolean: Bold text
        - `italic` boolean: Italic text
        - `underline` boolean: Underline text
        - `strikethrough` boolean: Strikethrough text
        - `fontColor` string: Font color (hex)
        - `backgroundColor` string: Background fill color (hex)
        - `fillPattern` 'SOLID_FOREGROUND' | 'FINE_DOTS' | 'ALT_BARS' | 'SPARSE_DOTS' | 'THICK_HORZ_BANDS' | 'THICK_VERT_BANDS' | 'THICK_BACKWARD_DIAG' | 'THICK_FORWARD_DIAG' | 'BIG_SPOTS' | 'BRICKS' | 'THIN_HORZ_BANDS' | 'THIN_VERT_BANDS' | 'THIN_BACKWARD_DIAG' | 'THIN_FORWARD_DIAG' | 'SQUARES' | 'DIAMONDS': Fill pattern
        - `horizontalAlignment` 'LEFT' | 'CENTER' | 'RIGHT' | 'JUSTIFY' | 'FILL': Horizontal alignment
        - `verticalAlignment` 'TOP' | 'CENTER' | 'BOTTOM' | 'JUSTIFY': Vertical alignment
        - `wrapText` boolean: Enable text wrapping
        - `rotation` integer: Text rotation in degrees (0-180)
        - `indent` integer: Indent level (number of spaces)
        - `borderStyle` 'NONE' | 'THIN' | 'MEDIUM' | 'THICK' | 'DOUBLE' | 'DOTTED' | 'DASHED': Border style for all four sides
        - `borderColor` string: Border color (hex, applied to all sides)
        - `numberFormat` string: Number format string
      - `dataStyle` ExcelCellStyle: Cell styling definition for Excel cells
        - `fontName` string: Font name
        - `fontSize` integer: Font size in points
        - `bold` boolean: Bold text
        - `italic` boolean: Italic text
        - `underline` boolean: Underline text
        - `strikethrough` boolean: Strikethrough text
        - `fontColor` string: Font color (hex)
        - `backgroundColor` string: Background fill color (hex)
        - `fillPattern` 'SOLID_FOREGROUND' | 'FINE_DOTS' | 'ALT_BARS' | 'SPARSE_DOTS' | 'THICK_HORZ_BANDS' | 'THICK_VERT_BANDS' | 'THICK_BACKWARD_DIAG' | 'THICK_FORWARD_DIAG' | 'BIG_SPOTS' | 'BRICKS' | 'THIN_HORZ_BANDS' | 'THIN_VERT_BANDS' | 'THIN_BACKWARD_DIAG' | 'THIN_FORWARD_DIAG' | 'SQUARES' | 'DIAMONDS': Fill pattern
        - `horizontalAlignment` 'LEFT' | 'CENTER' | 'RIGHT' | 'JUSTIFY' | 'FILL': Horizontal alignment
        - `verticalAlignment` 'TOP' | 'CENTER' | 'BOTTOM' | 'JUSTIFY': Vertical alignment
        - `wrapText` boolean: Enable text wrapping
        - `rotation` integer: Text rotation in degrees (0-180)
        - `indent` integer: Indent level (number of spaces)
        - `borderStyle` 'NONE' | 'THIN' | 'MEDIUM' | 'THICK' | 'DOUBLE' | 'DOTTED' | 'DASHED': Border style for all four sides
        - `borderColor` string: Border color (hex, applied to all sides)
        - `numberFormat` string: Number format string
    - `rows` ExcelRow[]: Data rows — each row contains a list of cells
      - `index` integer: Row index (0-based, excluding header). If omitted, rows are appended in list order.
      - `values` object[]: Cell values in column order. Strings are auto-detected: numbers become numeric cells, dates (yyyy-MM-dd) become date cells, booleans become boolean cells, everything else is text.
      - `cells` ExcelCell[]: Explicit cell definitions (alternative to 'values' for full control)
        - `ref` string: Cell reference in A1 notation (e.g. 'B3'). Required when used in sheet-level 'cells' array, optional inside a row.
        - `column` integer: Column index (0-based, alternative to ref — used inside rows)
        - `value` object: Cell value. Auto-detected type: number, boolean, date (yyyy-MM-dd), or string.
        - `type` 'STRING' | 'NUMERIC' | 'BOOLEAN' | 'DATE' | 'FORMULA' | 'BLANK': Explicit cell type override
        - `formula` string: Excel formula. A leading '=' is accepted and normalized automatically.
        - `format` string: Number/date format for this cell
        - `style` ExcelCellStyle: Cell styling definition for Excel cells
          - `fontName` string: Font name
          - `fontSize` integer: Font size in points
          - `bold` boolean: Bold text
          - `italic` boolean: Italic text
          - `underline` boolean: Underline text
          - `strikethrough` boolean: Strikethrough text
          - `fontColor` string: Font color (hex)
          - `backgroundColor` string: Background fill color (hex)
          - `fillPattern` 'SOLID_FOREGROUND' | 'FINE_DOTS' | 'ALT_BARS' | 'SPARSE_DOTS' | 'THICK_HORZ_BANDS' | 'THICK_VERT_BANDS' | 'THICK_BACKWARD_DIAG' | 'THICK_FORWARD_DIAG' | 'BIG_SPOTS' | 'BRICKS' | 'THIN_HORZ_BANDS' | 'THIN_VERT_BANDS' | 'THIN_BACKWARD_DIAG' | 'THIN_FORWARD_DIAG' | 'SQUARES' | 'DIAMONDS': Fill pattern
          - `horizontalAlignment` 'LEFT' | 'CENTER' | 'RIGHT' | 'JUSTIFY' | 'FILL': Horizontal alignment
          - `verticalAlignment` 'TOP' | 'CENTER' | 'BOTTOM' | 'JUSTIFY': Vertical alignment
          - `wrapText` boolean: Enable text wrapping
          - `rotation` integer: Text rotation in degrees (0-180)
          - `indent` integer: Indent level (number of spaces)
          - `borderStyle` 'NONE' | 'THIN' | 'MEDIUM' | 'THICK' | 'DOUBLE' | 'DOTTED' | 'DASHED': Border style for all four sides
          - `borderColor` string: Border color (hex, applied to all sides)
          - `numberFormat` string: Number format string
        - `comment` string: Comment/note to attach to this cell
        - `hyperlink` string: Hyperlink URL
      - `height` number, float: Row height in points
      - `style` ExcelCellStyle: Cell styling definition for Excel cells
        - `fontName` string: Font name
        - `fontSize` integer: Font size in points
        - `bold` boolean: Bold text
        - `italic` boolean: Italic text
        - `underline` boolean: Underline text
        - `strikethrough` boolean: Strikethrough text
        - `fontColor` string: Font color (hex)
        - `backgroundColor` string: Background fill color (hex)
        - `fillPattern` 'SOLID_FOREGROUND' | 'FINE_DOTS' | 'ALT_BARS' | 'SPARSE_DOTS' | 'THICK_HORZ_BANDS' | 'THICK_VERT_BANDS' | 'THICK_BACKWARD_DIAG' | 'THICK_FORWARD_DIAG' | 'BIG_SPOTS' | 'BRICKS' | 'THIN_HORZ_BANDS' | 'THIN_VERT_BANDS' | 'THIN_BACKWARD_DIAG' | 'THIN_FORWARD_DIAG' | 'SQUARES' | 'DIAMONDS': Fill pattern
        - `horizontalAlignment` 'LEFT' | 'CENTER' | 'RIGHT' | 'JUSTIFY' | 'FILL': Horizontal alignment
        - `verticalAlignment` 'TOP' | 'CENTER' | 'BOTTOM' | 'JUSTIFY': Vertical alignment
        - `wrapText` boolean: Enable text wrapping
        - `rotation` integer: Text rotation in degrees (0-180)
        - `indent` integer: Indent level (number of spaces)
        - `borderStyle` 'NONE' | 'THIN' | 'MEDIUM' | 'THICK' | 'DOUBLE' | 'DOTTED' | 'DASHED': Border style for all four sides
        - `borderColor` string: Border color (hex, applied to all sides)
        - `numberFormat` string: Number format string
    - `cells` ExcelCell[]: Named cells with explicit positioning (e.g. for formulas, labels, or sparse data)
      - `ref` string: Cell reference in A1 notation (e.g. 'B3'). Required when used in sheet-level 'cells' array, optional inside a row.
      - `column` integer: Column index (0-based, alternative to ref — used inside rows)
      - `value` object: Cell value. Auto-detected type: number, boolean, date (yyyy-MM-dd), or string.
      - `type` 'STRING' | 'NUMERIC' | 'BOOLEAN' | 'DATE' | 'FORMULA' | 'BLANK': Explicit cell type override
      - `formula` string: Excel formula. A leading '=' is accepted and normalized automatically.
      - `format` string: Number/date format for this cell
      - `style` ExcelCellStyle: Cell styling definition for Excel cells
        - `fontName` string: Font name
        - `fontSize` integer: Font size in points
        - `bold` boolean: Bold text
        - `italic` boolean: Italic text
        - `underline` boolean: Underline text
        - `strikethrough` boolean: Strikethrough text
        - `fontColor` string: Font color (hex)
        - `backgroundColor` string: Background fill color (hex)
        - `fillPattern` 'SOLID_FOREGROUND' | 'FINE_DOTS' | 'ALT_BARS' | 'SPARSE_DOTS' | 'THICK_HORZ_BANDS' | 'THICK_VERT_BANDS' | 'THICK_BACKWARD_DIAG' | 'THICK_FORWARD_DIAG' | 'BIG_SPOTS' | 'BRICKS' | 'THIN_HORZ_BANDS' | 'THIN_VERT_BANDS' | 'THIN_BACKWARD_DIAG' | 'THIN_FORWARD_DIAG' | 'SQUARES' | 'DIAMONDS': Fill pattern
        - `horizontalAlignment` 'LEFT' | 'CENTER' | 'RIGHT' | 'JUSTIFY' | 'FILL': Horizontal alignment
        - `verticalAlignment` 'TOP' | 'CENTER' | 'BOTTOM' | 'JUSTIFY': Vertical alignment
        - `wrapText` boolean: Enable text wrapping
        - `rotation` integer: Text rotation in degrees (0-180)
        - `indent` integer: Indent level (number of spaces)
        - `borderStyle` 'NONE' | 'THIN' | 'MEDIUM' | 'THICK' | 'DOUBLE' | 'DOTTED' | 'DASHED': Border style for all four sides
        - `borderColor` string: Border color (hex, applied to all sides)
        - `numberFormat` string: Number format string
      - `comment` string: Comment/note to attach to this cell
      - `hyperlink` string: Hyperlink URL
    - `namedRanges` ExcelNamedRange[]: Named ranges for structured references
      - `name` string, required: Name of the range
      - `range` string, required: Range reference in A1 notation
    - `formulas` ExcelFormula[]: Formulas to place at specific cell positions
      - `cell` string, required: Cell reference in A1 notation
      - `formula` string, required: Excel formula. A leading '=' is accepted and normalized automatically.
      - `label` string: Optional label to place in the cell to the left
      - `format` string: Number format for the formula result
      - `style` ExcelCellStyle: Cell styling definition for Excel cells
        - `fontName` string: Font name
        - `fontSize` integer: Font size in points
        - `bold` boolean: Bold text
        - `italic` boolean: Italic text
        - `underline` boolean: Underline text
        - `strikethrough` boolean: Strikethrough text
        - `fontColor` string: Font color (hex)
        - `backgroundColor` string: Background fill color (hex)
        - `fillPattern` 'SOLID_FOREGROUND' | 'FINE_DOTS' | 'ALT_BARS' | 'SPARSE_DOTS' | 'THICK_HORZ_BANDS' | 'THICK_VERT_BANDS' | 'THICK_BACKWARD_DIAG' | 'THICK_FORWARD_DIAG' | 'BIG_SPOTS' | 'BRICKS' | 'THIN_HORZ_BANDS' | 'THIN_VERT_BANDS' | 'THIN_BACKWARD_DIAG' | 'THIN_FORWARD_DIAG' | 'SQUARES' | 'DIAMONDS': Fill pattern
        - `horizontalAlignment` 'LEFT' | 'CENTER' | 'RIGHT' | 'JUSTIFY' | 'FILL': Horizontal alignment
        - `verticalAlignment` 'TOP' | 'CENTER' | 'BOTTOM' | 'JUSTIFY': Vertical alignment
        - `wrapText` boolean: Enable text wrapping
        - `rotation` integer: Text rotation in degrees (0-180)
        - `indent` integer: Indent level (number of spaces)
        - `borderStyle` 'NONE' | 'THIN' | 'MEDIUM' | 'THICK' | 'DOUBLE' | 'DOTTED' | 'DASHED': Border style for all four sides
        - `borderColor` string: Border color (hex, applied to all sides)
        - `numberFormat` string: Number format string
    - `mergedRegions` string[]: Merge cell ranges
    - `headerFooter` ExcelHeaderFooter: Print header and footer for an Excel sheet. Supports Apache POI format codes: &L=left, &C=center, &R=right, &P=page number, &N=total pages, &D=date, &T=time, &F=filename
      - `header` string: Header text with formatting codes
      - `footer` string: Footer text with formatting codes
      - `headerLeft` string: Left section of the header
      - `headerCenter` string: Center section of the header
      - `headerRight` string: Right section of the header
      - `footerLeft` string: Left section of the footer
      - `footerCenter` string: Center section of the footer
      - `footerRight` string: Right section of the footer
    - `printArea` string: Print area in A1 notation
    - `freezePane` ExcelFreezePane: Freeze pane configuration — rows and columns that remain visible while scrolling
      - `row` integer, required: Number of rows to freeze (from top). 1 = freeze header row.
      - `col` integer: Number of columns to freeze (from left). 0 = no column freeze.
    - `headerStyle` ExcelCellStyle: Cell styling definition for Excel cells
      - `fontName` string: Font name
      - `fontSize` integer: Font size in points
      - `bold` boolean: Bold text
      - `italic` boolean: Italic text
      - `underline` boolean: Underline text
      - `strikethrough` boolean: Strikethrough text
      - `fontColor` string: Font color (hex)
      - `backgroundColor` string: Background fill color (hex)
      - `fillPattern` 'SOLID_FOREGROUND' | 'FINE_DOTS' | 'ALT_BARS' | 'SPARSE_DOTS' | 'THICK_HORZ_BANDS' | 'THICK_VERT_BANDS' | 'THICK_BACKWARD_DIAG' | 'THICK_FORWARD_DIAG' | 'BIG_SPOTS' | 'BRICKS' | 'THIN_HORZ_BANDS' | 'THIN_VERT_BANDS' | 'THIN_BACKWARD_DIAG' | 'THIN_FORWARD_DIAG' | 'SQUARES' | 'DIAMONDS': Fill pattern
      - `horizontalAlignment` 'LEFT' | 'CENTER' | 'RIGHT' | 'JUSTIFY' | 'FILL': Horizontal alignment
      - `verticalAlignment` 'TOP' | 'CENTER' | 'BOTTOM' | 'JUSTIFY': Vertical alignment
      - `wrapText` boolean: Enable text wrapping
      - `rotation` integer: Text rotation in degrees (0-180)
      - `indent` integer: Indent level (number of spaces)
      - `borderStyle` 'NONE' | 'THIN' | 'MEDIUM' | 'THICK' | 'DOUBLE' | 'DOTTED' | 'DASHED': Border style for all four sides
      - `borderColor` string: Border color (hex, applied to all sides)
      - `numberFormat` string: Number format string
    - `dataStyle` ExcelCellStyle: Cell styling definition for Excel cells
      - `fontName` string: Font name
      - `fontSize` integer: Font size in points
      - `bold` boolean: Bold text
      - `italic` boolean: Italic text
      - `underline` boolean: Underline text
      - `strikethrough` boolean: Strikethrough text
      - `fontColor` string: Font color (hex)
      - `backgroundColor` string: Background fill color (hex)
      - `fillPattern` 'SOLID_FOREGROUND' | 'FINE_DOTS' | 'ALT_BARS' | 'SPARSE_DOTS' | 'THICK_HORZ_BANDS' | 'THICK_VERT_BANDS' | 'THICK_BACKWARD_DIAG' | 'THICK_FORWARD_DIAG' | 'BIG_SPOTS' | 'BRICKS' | 'THIN_HORZ_BANDS' | 'THIN_VERT_BANDS' | 'THIN_BACKWARD_DIAG' | 'THIN_FORWARD_DIAG' | 'SQUARES' | 'DIAMONDS': Fill pattern
      - `horizontalAlignment` 'LEFT' | 'CENTER' | 'RIGHT' | 'JUSTIFY' | 'FILL': Horizontal alignment
      - `verticalAlignment` 'TOP' | 'CENTER' | 'BOTTOM' | 'JUSTIFY': Vertical alignment
      - `wrapText` boolean: Enable text wrapping
      - `rotation` integer: Text rotation in degrees (0-180)
      - `indent` integer: Indent level (number of spaces)
      - `borderStyle` 'NONE' | 'THIN' | 'MEDIUM' | 'THICK' | 'DOUBLE' | 'DOTTED' | 'DASHED': Border style for all four sides
      - `borderColor` string: Border color (hex, applied to all sides)
      - `numberFormat` string: Number format string
    - `defaultColumnWidth` integer: Default column width in characters
    - `defaultRowHeight` number, float: Default row height in points
    - `autoSizeColumns` boolean: Auto-size columns to fit content
    - `autoFilter` boolean: Enable auto-filter on the header row
    - `pageOrientation` 'PORTRAIT' | 'LANDSCAPE': Page orientation for printing
    - `fitToPage` boolean: Fit sheet to one page width when printing
    - `protectionPassword` string: Protection password for this sheet (prevents editing)
  - `properties` object: Document properties (author, title, subject, etc.)
  - `password` string: Password to protect the workbook

## Response `200`

Generated XLSX file

## Other responses

- `400`: Invalid request

---

[API](https://skmtc.dev/dokmatiq/apis/docgen-api.md) · [All operations](https://skmtc.dev/dokmatiq/apis/docgen-api/llms.txt) · [OpenAPI document](https://skmtc.dev/dokmatiq/apis/docgen-api/revisions/3fa1a922764d?raw)
