Excel export from .NET reports
When people ask for “Export to Excel”, they want numbers they can add up, sort and filter, not a picture of the
page. Tagua’s Tagua.Excel package makes a workbook from the same template and data as the PDF, built from the
report’s data rather than its pages:
- Real numbers and dates. A text that is one expression, such as
{Amount:C}or{Issued:d}, becomes a number or a date with the matching Excel format, soSUMand sorting work, and it still reads like the PDF. A format taken from the data,{Format(Amount, AmountFormat)}, works the same way. - Rows from bands. Each detail row, group header and footer becomes a row; values fall into columns that follow the report’s layout, and a value that spans several columns in the report spans them in the sheet.
- Collapsible groups. Groups get Excel’s outline levels, so each folds into its total.
- A frozen header. The page header’s column titles sit at the top and stay in view.
An example
Section titled “An example”The grouped list as a workbook: the column titles frozen, each letter’s countries a
level below its header and total, and the populations stored as numbers with a #,##0 format.
Download the workbook.
| A | B | C | ||
|---|---|---|---|---|
| 1 | Country List | |||
| 2 | Name | Population | Continent | |
| 3 | Countries starting with letter: A | |||
| 4 | │ | Albania | 2,750,000 | Europe |
| 5 | │ | Algeria | 45,600,000 | Africa |
| 6 | │ | Argentina | 46,000,000 | South America |
| 7 | │ | Australia | 26,600,000 | Oceania |
| 8 | │ | Austria | 9,100,000 | Europe |
| 9 | 5 countries, 130,050,000 people | |||
| 10 | Countries starting with letter: B | |||
| 11 | │ | Bangladesh | 171,500,000 | Asia |
| 12 | │ | Belgium | 11,800,000 | Europe |
| 13 | │ | Bolivia | 12,400,000 | South America |
| 14 | │ | Brazil | 203,000,000 | South America |
| 15 | │ | Bulgaria | 6,450,000 | Europe |
| 16 | 5 countries, 405,150,000 people | |||
| 17 | Countries starting with letter: C | |||
| 18 | │ | Canada | 40,100,000 | North America |
| 19 | │ | Chile | 19,600,000 | South America |
| 20 | │ | China | 1,410,000,000 | Asia |
| 21 | │ | Colombia | 52,200,000 | South America |
| 22 | │ | Croatia | 3,850,000 | Europe |
| 23 | 5 countries, 1,525,750,000 people | |||
| 24 | Countries starting with letter: D | |||
And the invoice: prices and amounts stored as numbers with a euro format, VAT as a percentage, and the totals under the Amount column, with their labels spanning the columns before it as in the PDF. Download the workbook.
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Invoice | ||||||
| 2 | No. INV-0042 | ||||||
| 3 | Issued 01/09/2026 · Due 01/10/2026 | ||||||
| 4 | Bill to | ||||||
| 5 | Contoso Ltd 1 Main Street Dublin D02 | ||||||
| 6 | Description | Qty | Unit price | VAT | Amount | ||
| 7 | Consulting (hourly, remote) | 3 | €0.10 | 23% | €0.30 | ||
| 8 | Support contract — September | 2 | €100.00 | 23% | €200.00 | ||
| 9 | Net | €200.30 | |||||
| 10 | VAT | €46.07 | |||||
| 11 | Total due | €246.37 | |||||
| 12 | How to pay | ||||||
| 13 | Transfer €246.37 to IBAN IE29AIBK93115212345678 by Thursday 1 October 2026, quoting INV-0042, or scan the code with your banking app. | ||||||
Hover over a number to see its Excel format.
From C#
Section titled “From C#”-
Add the package:
Terminal window dotnet add package Tagua.Excel -
Render the report as a workbook:
using Tagua;using Tagua.Excel;TaguaSettings.License = LicenseType.Community;var report = CompiledReport.Compile(TemplateLoader.LoadFile("sales.report.yaml"));await using var xlsx = File.Create("sales.xlsx");var result = await ExcelReports.RenderExcelAsync(report, inputs, xlsx);foreach (var diagnostic in result.Diagnostics) Console.WriteLine(diagnostic);To make the PDF and the workbook from one read of the data, fill the report once and give the result to both:
new ExcelRenderer().Render(filled, xlsx)takes theFilledReportthatReportFiller.FillAsyncreturns.
From the command line, the output’s extension picks the format:
tagua render sales.report.yaml --out sales.xlsxFormats
Section titled “Formats”The template’s .NET formats become Excel number formats, in the report’s culture:
| In the template | Excel format | Shows |
|---|---|---|
{Amount:C} (en-US) |
"$"#,##0.00 |
$1,234.50 |
{Amount:C} (de-DE) |
#,##0.00\ "€" |
1.234,50 € |
{Amount:N0} |
#,##0 |
1,235 |
{Rate:P1} |
#,##0.0% |
25.6% |
{Number:D5} |
00000 |
00042 |
{Weight:0.0 'kg'} |
0.0\ "kg" |
3.5 kg |
{Issued:yyyy-MM-dd} |
yyyy"-"mm"-"dd |
2026-09-24 |
{Issued:d} (en-US) |
m"/"d"/"yyyy |
9/24/2026 |
A value keeps its full precision: a VAT of 46.069 is stored as 46.069 and shown as €46.07, as Excel users expect.
What has no faithful Excel equivalent stays text, exactly as the PDF shows it: hexadecimal (X), dates before
March 1900 (where Excel’s calendar is off by a day), and text that mixes words and values.
What else carries over
Section titled “What else carries over”- Styles: fonts, bold, italic, colours, fills, borders and alignment.
- Tables keep their columns, header row and footer rows, and their own border and background: the edge cells carry the border and every cell the background (a sheet has no room for the padding). Subreports are laid out in place.
- Right-to-left rows and tables start at the right, as in the report.
- Printing fits the columns to the page’s width, in the report’s orientation.
- Page footers are left out: a sheet has no pages.
Images, barcodes and charts
Section titled “Images, barcodes and charts”- Images become pictures in their cells, sized as in the PDF: the element’s width, its height or the image’s
proportions, and its
fit. Whatcoverandnoneclip is cropped. The row grows to the picture’s height. - Barcodes become pictures of their symbols, the same size as in the PDF, with every module a whole number of pixels, so they stay sharp and scanners read them from the sheet. CI decodes every sample barcode from its workbook.
- Charts become native Excel charts of the same kind, with their title, legend, labels, colours and number format. An Excel chart reads its values from cells, so each chart’s categories and values go on a second sheet, Chart data. Edit a value there and the chart follows.
- Sparklines (charts under 60pt tall) become Excel’s own sparklines, drawn in their cell, where those draw the same thing: one series, as a line or as columns. They read their values from the Chart data sheet, one row each, and span the same range as in the PDF. Other sparklines (several series, bars, areas, pies, negative columns) become small charts without axes, legend or title.
Images need the same resource resolver as the PDF; RenderExcelAsync takes it from the inputs, and ExcelRenderer
from ExcelOptions.Resources.
The workbook is written without any other library, runs under native AOT, and gives the same bytes for the same input.