XTL Cookbook
Focused, copy-paste recipes for common reporting workflows. Each recipe is a short markdown page with a scenario, the template cells, and the expected output.
The cookbook complements two existing surfaces:
examples/holds three runnable templates (renewal-report,sheet-per-region,multi-source-join) that exercise composed shapes end-to-end. Copy one as a starting point.spec/language.mdis the normative reference for each function and directive. Use it when a recipe doesn't cover your exact case.
Recipes here favor "the smallest template that demonstrates X" over production realism — the goal is fast lookup when you remember the shape but forget the syntax.
Recipes
| # | Recipe | What you'll learn |
|---|---|---|
| 01 | Getting started in 5 minutes | Template + data → output. Substitution and __config__. |
| 02 | Conditional cells | IF, IFEMPTY, comparison operators, truthiness. |
| 03 | Aggregates over rows | SUM, COUNT, AVERAGE, MIN, MAX — block vs whole-source. |
| 04 | One file per group | File grouping via output_file_pattern. |
| 05 | One sheet per group | Sheet grouping + list-based filtering. |
| 06 | Runtime inputs | __inputs__ for per-run values (month, region, etc.). |
| 07 | Multi-source + @join | __sources__, @source, @join. |
| 08 | XLOOKUP | Cross-source lookups. |
| 09 | Sort and Top-N | @sort (stable), @top, multi-key sort. |
| 10 | Styling and branding | tabColor, merged cells, numFmt, TEXT(). |
| 11 | TEXT() formatting | Currency, dates, percentages; when to use numFmt vs TEXT(). |
| 12 | Empty values in depth | IFEMPTY, empty-vs-zero traps, (blank), aggregates over sparse data. |
| 13 | Error handling for hosts | Catching XtlError, the code catalog, preview() for fail-fast. |
| 14 | __config__ as a value dictionary | Author-defined keys, type-awareness, __config__ vs __inputs__. |
| 15 | Composing directives | Execution order, multi-@filter AND, forbidden compositions. |
How to read a recipe
Each recipe has the same shape:
- Scenario — the operator's goal in one sentence.
__config__— required keys.- Template cells — the smallest set of cells that produce the goal.
- Data — a tiny input table.
- Output — what
convert()returns. - Notes — gotchas and pointers to the spec when you want more.
Conventions
- Cells use the
A1notation Excel uses, not[row, col]. __config__values are written askey = valuefor compactness; in a realtemplate.xlsxthey live in two columns (A: key,B: value).- Source data is shown as a markdown table to keep the recipe terse.
The real
data.xlsxwould have those rows in a worksheet matchingsource_sheet.
Running a recipe
The cookbook recipes are documentation-first — not every recipe ships
with a runnable .xlsx pair. To try one:
- Open Excel and create a new workbook.
- Add the
__config__sheet with the keys listed. - Add the data sheet matching
source_sheet. - Add the template sheet with the cells from the recipe.
- Save as
template.xlsx. Save the data asdata.xlsx. - Run
convert(templateBuffer, dataBuffer)(see README).
Or, faster: copy one of the runnable examples and adapt it.