Excel style
Syntax
excelStyle(style: $value)
Description
Creates a style object that can be used to format Excel cells. This function makes it possible to define formatting and apply it to multiple cells. By using excelStyle(), you can define and reuse formatting centrally.
Parameters
| name | Type | Type Description | Mandatory | Default |
|---|---|---|---|---|
| color | Character string | Font color of the cell. Supports color names (e.g. "red", "blue") or hex codes (e.g. "#FF0000"). | no | null |
| background | Character string | Background color of the cell. Supports color names or hex codes. | no | null |
| bold | Boolean | Determines whether the text should be displayed in bold. | no | null |
| italic | Boolean | Determines whether the text should be displayed in italics. | no | null |
| fontSize | Number | Font size in points. | no | null |
| fontFamily | Character string | Font name (e.g. "Arial", "Calibri", "Times New Roman"). | no | null |
| borderTop | Character string | Upper border style. Supports values such as "thin", "medium", "thick", "double", "dashed", "dotted". | no | null |
| borderBottom | Character string | Bottom border style. | no | null |
| borderLeft | Character string | Left border style. | no | null |
| borderRight | Character string | Right border style. | no | null |
| align | Character string | Horizontal alignment. Supports "left", "center", "right", "fill", "justify". | no | null |
| valign | Character string | Vertical alignment. Supports "top", "center", "bottom". | no | null |
| numberFormat | Character string | Number format for the cell (e.g. "$#,##0.00", "0.00%", "DD.MM.YYYY"). | no | null |
| rowSpan | Number | Number of rows over which the cell should span (cell merge). | no | null |
| colSpan | number | Number of columns over which the cell should extend (cell merge). | no | null |
Return value
Type: Map
A Map object containing the style information for use in excelCell().
Examples
Simple header style
// Header-Stil definieren
headerStyle = excelStyle(
bold: true,
background: "#4472C4",
color: "white",
align: "center",
borderBottom: "thick"
)
// Anwendung in Zellen
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 and bold white font.
Currency format style
// Währungsformat-Stil
currencyStyle = excelStyle(
numberFormat: "$#,##0.00",
align: "right",
bold: true
)
// Anwendung
excelCell(row: 5, col: 1, content: 1250.50, style: $currencyStyle)
excelCell(row: 6, col: 1, content: 899.99, style: $currencyStyle)
Output: Two cells with currency format: "$1,250.50" and "$899.99", right-aligned and bold.
Complete table style
// Definition verschiedener Stile für eine Tabelle
headerStyle = excelStyle(
bold: true,
background: "#2C3E50",
color: "white",
align: "center",
borderBottom: "double",
borderTop: "double",
borderLeft: "thin",
borderRight: "thin"
)
dataStyle = excelStyle(
align: "right",
numberFormat: "#,##0.00",
borderLeft: "thin",
borderRight: "thin"
)
highlightStyle = excelStyle(
background: "#FFF3CD",
bold: true,
color: "#856404",
borderLeft: "thin",
borderRight: "thin"
)
// Anwendung in einer Tabelle
excelCell(row: 0, col: 0, content: "Monat", style: $headerStyle)
excelCell(row: 0, col: 1, content: "Umsatz", style: $headerStyle)
excelCell(row: 0, col: 2, content: "Kosten", style: $headerStyle)
excelCell(row: 1, col: 0, content: "Januar", style: $dataStyle)
excelCell(row: 1, col: 1, content: 50000, style: $dataStyle)
excelCell(row: 1, col: 2, content: 35000, style: $dataStyle)
excelCell(row: 2, col: 0, content: "Februar", style: $dataStyle)
excelCell(row: 2, col: 1, content: 55000, style: $highlightStyle)
excelCell(row: 2, col: 2, content: 38000, style: $dataStyle)
Output: Fully formatted table with different styles for header, data and highlighted values.