Excel creation

Syntax

	excelFile(content: $content, name: $fileName)

Description

Creates an Excel file with the specified name and content. The function generates a complete Excel file (.xlsx format) with one or more worksheets, cell contents, formulas and formatting. The function returns the generated Excel file as a BinaryData object, which can be used for downloading or further processing.

Parameters

File name Type Type Description Mandatory Default
Content List A list of worksheets to be created in the Excel file. Typically created with excelSheet(). yes
name Character string The file name of the Excel file to be created (e.g. "report"). no "data"

Return value

Type: BinaryData

The Excel file created as a BinaryData object that can be downloaded or further processed.

Examples

Simple Excel file with one worksheet

	excelFile(
    name: "verkaufsbericht",
    content: [
      excelSheet(
        name: "Q1 2024",
        content: [
          ["Produkt", "Januar", "Februar", "März"],
          ["Widget A", 1000, 1500, 1200],
          ["Widget B", 800, 900, 1100]
        ]
      )
    ]
  )

Output: Excel file with one worksheet "Q1 2024" and sales data.

Excel file with multiple worksheets and cell formatting

	excelFile(
    name: "komplexer_bericht",
    content: [
        excelSheet(
            name: "Zusammenfassung",
            content: [
                excelCell(row: 0, col: 0, content: "Monatsbericht",
                    style: excelStyle(bold: true, fontSize: 16, background: "#2C3E50", color: "white")),
                excelCell(row: 2, col: 0, content: "Gesamtumsatz", style: excelStyle(bold: true)),
                excelCell(row: 2, col: 1, content: excelFormula("SUM(Details!B2:B4)"),
                    style: excelStyle(numberFormat: "$#,##0.00", background: "#E8F6F3"))
            ]
        ),
        excelSheet(
            name: "Details",
            content: [
                ["Monat", "Umsatz", "Kosten"],
                ["Januar", 50000, 35000],
                ["Februar", 55000, 38000],
                ["März", 60000, 40000]
            ]
        )
    ]
  )

Output: Excel file with two worksheets, formatted cells and formulas.