Excel cell
Syntax
excelCell(content: $content, row: $row, col: $col, style: $cellStyle)
Description
Creates a single cell with specific position, content and formatting. This function is used within excelSheet() to gain precise control over the placement and appearance of cells.
The function supports different content types (text, numbers, boolean, formulas) and extensive formatting options such as fonts, colors, borders, alignment and number formats.
Parameters
| Cell name | Type | Type Description | Mandatory | Default |
|---|---|---|---|---|
| Content | Object | The content of the cell. This can be text, numbers, Boolean values, an Excel formula (created with excelFormula()) or a nested list of cells. | yes | |
| row | Number | The row number of the cell (0-based). If not specified, the current cursor position is used. | no | null |
| col | number | The column number of the cell (0-based). If not specified, the current cursor position is used. | no | null |
| style | ExcelStyle | A style object created with excelStyle(). | no | null |
Return value
Type: Map
A Map object containing the cell information for processing by excelSheet().
Examples
Simple cell with text content
excelCell(row: 0, col: 0, content: "Hello World")
Output: Cell in row 0, column 0 with the text "Hello World". The current cursor position after this expression would be: Row 0, Col 1.
Cell with number formatting
excelCell(row: 1, col: 1, content: 1250.50,
style: excelStyle(numberFormat: "$#,##0.00", align: "right"))
Output: Cell with currency format: "$1,250.50", right-aligned.
Cell with comprehensive formatting
excelCell(row: 3, col: 0, content: "Wichtiger Hinweis",
style: {
"bold": true,
"italic": true,
"color": "#DC3545",
"background": "#F8D7DA",
"fontSize": 12,
"borderTop": "medium",
"borderBottom": "medium",
"borderLeft": "medium",
"borderRight": "medium",
"align": "center",
"valign": "center"
})
Output: Red, bold italic font on a light red background with frame and centered alignment.
Cell with Excel formula
excelCell(row: 5, col: 2, content: excelFormula("SUM(A5:A10)"),
style: excelStyle(numberFormat: "$#,##0.00", bold: true, background: "#E8F5E8"))
Output: Cell with Excel formula that calculates the sum of cells A5 to A10, with currency format and green background.
Reusable styles
// Stildefinition
headerStyle = excelStyle(
bold: true,
background: "#007BFF",
color: "white",
align: "center",
borderBottom: "thick"
);
// Anwendung des Stils
excelCell(row: 0, col: 0, content: "Produkt", style: $headerStyle)
excelCell(row: 0, col: 1, content: "Preis", style: $headerStyle)
excelCell(row: 0, col: 2, content: "Bestand", style: $headerStyle)
Output: Three header cells with uniform blue header style.
Cells with cursor-based positioning
// Zellen werden automatisch platziert (Cursor-Modus)
excelCell(content: "Produkt") // row: 0, col: 0
excelCell(content: "Preis") // row: 0, col: 1
excelCell(content: "Bestand") // row: 0, col: 2
excelCell(content: "Widget A") // row: 1, col: 0
excelCell(content: 29.99) // row: 1, col: 1
excelCell(content: 150) // row: 1, col: 2
// Manuelle Positionierung für Überschrift
excelCell(row: 3, col: 0, content: "Gesamtsumme", style: excelStyle(bold: true))
excelCell(row: 3, col: 1, content: excelFormula("SUM(B2:B4)"), style: excelStyle(numberFormat: "$#,##0.00"))
Output: Table with automatic placement for data cells and manual positioning for the totals row.
Nested tables (excelCell as content)
// Hauptzelle mit verschachtelter Tabelle
excelCell(
row: 0,
col: 0,
content: [
["Detail A", "Detail B", "Detail C"],
[100, 200, 300],
[150, 250, 350]
],
style: excelStyle(
borderTop: "thick",
borderBottom: "thick",
borderLeft: "thick",
borderRight: "thick"
)
)
// Zelle mit verschachtelten, formatierten Zellen
excelCell(
row: 5,
col: 0,
content: [
excelCell(content: "Header", style: excelStyle(bold: true, background: "#E8F5E8")),
excelCell(content: "Value", style: excelStyle(numberFormat: "#,##0.00", align: "right"))
]
)
Output: Cells that contain even small tables or formatted cell groups.