Skip to main content
This capability is under development. It is available in homologation on Lerian Cloud, and its behavior can change before release. Confirm availability with Lerian before integration.
This page shows how to create an operations report as an .xlsx spreadsheet with Reporter. You write a text template that declares the workbook. Reporter renders the text, then converts it into the spreadsheet file. Reporter converts only custom reports to xlsx. Regulatory filings are generated another way and are not converted.

Declare the workbook


A template with output format xlsx is a .tpl text file like every other format. Its rendered text must be a declared workbook. The declaration uses four elements, nested in this order:
  1. workbook: the root. A template has one.
  2. sheet: one sheet of the file. A workbook holds one or more.
  3. row: one row of a sheet.
  4. cell: one cell of a row. A cell holds text only.
Each element takes only the attributes in this table. Reporter refuses a rendered text that breaks these rules:
  • Any other element, attribute or namespace.
  • A repeated attribute.
  • Text outside a cell. Only white space may stand between elements.
  • A type value that is not text, number or date. The value is case-sensitive.
  • A processing instruction or a DOCTYPE. An XML declaration is accepted only at the start of the text, with version 1.0 and UTF-8.
Comments are ignored. A cell without type is a text cell. When you create or update an xlsx template, Reporter checks that the text holds <workbook. If it does not, Reporter answers 400 RPT-0007. A template cannot declare these items. Every cell uses one Calibri 11 font.
  • Column widths
  • Styles and fonts
  • Formulas
  • Merged cells
  • Hidden sheets
The template builder wraps the generated body in <workbook> when the format is xlsx. It offers no sheet, row or cell block, so you write those in the template code.

Template code

This template loops over the operations of a ledger. It writes one sheet named Operations. The first row is a header. Each operation adds one row of typed cells.

Code breakdown

<sheet name="Operations"> Starts the only sheet of the workbook. <row> with <cell> header text The first row has seven text cells. {%- for operation in midaz_transaction.operation %} Runs the row block once for each operation. Each pass writes one row. <cell type="number">{{ operation.amount|decimal:2 }}</cell> Writes the amount as a number with two decimal places. The decimal filter keeps the trailing zeros. It also rounds to the number of places you give. Use the largest scale among the assets the report reads, up to 15 places. See Cell types. <cell type="date">{% date_time "YYYY-MM-dd" %}</cell> Writes the generation date in the time zone of the server, such as 2026-11-24. In the date_time format the day is dd. DD prints as literal text, and the date cell refuses it. To write a date from your data, format it with the date filter. Reporter refuses a raw timestamp in a date cell.
Reporter escapes the values a template prints. A & or < in your data reaches the cell as the original character. Text you write in the template itself is XML. Write &amp; and &lt; there.

Template output

The template preview answers the declared workbook as XML. The report is the spreadsheet file, with the same cells.

Cell types


A cell has one of three types. Integers and decimals are both number. A template cannot declare boolean, datetime or error cells.

Text cells

A text cell keeps every character between its tags. Surrounding white space and line breaks stay. A raw CR or CRLF becomes LF. A text cell that starts with = stays text. Reporter never stores it as a formula.

The trailing-zero trap

Before the conversion, Reporter removes trailing zeros from numbers in the whole rendered text. This includes text cells. The value 1.500 is written as 1.5. To keep the zeros, print the value with the decimal filter and a number of places:
This prints 1.500. The filter rounds to the places you give. In a number cell, use at most 15 places: 16 or more fails the report, even for 1.5.

Number cells

A number has an optional -, then digits, and optionally . followed by digits. Reporter refuses these forms:
  • A leading +
  • An exponent
  • A group separator
  • .5 and 5.
A number has at most 15 significant digits and at most 15 digits after the point. Reporter refuses a longer number. It never rounds it. A number with n digits after the point shows exactly n decimals. An integer uses the General format.

Date cells

A date is exactly YYYY-MM-DD, from 1900-03-01 to 9999-12-31. A date carries no time.

Empty cells

A number or date cell is trimmed of surrounding space, tab, CR and LF. A cell that is empty after the trim writes nothing. The cell keeps its column, so columns are positional.

Limits


None of these limits is configurable. A character outside the basic plane, such as an emoji, counts as two. A sheet name must meet these rules:
  • It has no control character.
  • It has none of / \ ? * : [ ].
  • It does not start or end with an apostrophe.
  • It is not History, in any letter case.
  • It holds no literal _xHHHH_.
  • It does not repeat the name of another sheet, in any letter case.
Sheets appear in the declared order. Rows are numbered one after another, and an empty <row/> counts as a row.

Failures


A refused conversion ends the report in Error. Reporter stores no file and does not retry the report. The report metadata records error, error_code and error_title. RPT-0252 also covers invalid UTF-8 and any character that XML 1.0 forbids. RPT-0253 gives one of four reasons:
  1. The value does not fit its cell type.
  2. The sheet name is refused.
  3. A workbook limit is reached.
  4. The workbook has no sheet.
Positions in RPT-0253 start at 1. Some positions are 0:
  • A refused sheet name has row 0 and column 0.
  • An empty workbook has sheet 0, row 0 and column 0.
  • The row limit and the 4 GiB limit have column 0.
Neither message carries a cell value or a sheet name. Conversion stops at the first refusal.

Preview

The template preview answers the rendered declared workbook as application/xml, not as a spreadsheet. It also runs the conversion. If the conversion is refused, the preview answers 400 with RPT-0252 or RPT-0253. The preview renders up to 5 MiB. If it cuts the output at that size, it warns β€œOutput truncated at 5 MiB; the rendered document is larger.” and skips the conversion check.

In the Console

The template builder preview says β€œThe preview shows the declared workbook; the report is the spreadsheet”. An xlsx report has no on-screen preview. The report preview says β€œThis report is a spreadsheet and has no preview. Download it to open it.” Only a finished report downloads. Other states answer 422 RPT-0029. The API download answers the media type application/vnd.openxmlformats-officedocument.spreadsheetml.sheet with the file name <reportId>.xlsx. The Console names the downloaded file after the template. It uses lowercase letters and underscores for spaces. It adds the UTC date of the download: <template>_<yyyy-mm-dd>.xlsx.

Next steps


Template reference

Every tag and filter, including decimal.

Template engine

How Reporter renders a template.

Template examples

Worked templates for the other output formats.

Download a report

Download the finished spreadsheet from the Console.

File datasets

Read delivered files as data for your reports.

Read an xlsx file as a dataset day

The opposite direction: xlsx as input.