ExcelReportLib 2.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package ExcelReportLib --version 2.0.0
                    
NuGet\Install-Package ExcelReportLib -Version 2.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ExcelReportLib" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ExcelReportLib" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="ExcelReportLib" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ExcelReportLib --version 2.0.0
                    
#r "nuget: ExcelReportLib, 2.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ExcelReportLib@2.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ExcelReportLib&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=ExcelReportLib&version=2.0.0
                    
Install as a Cake Tool

ExcelReportLib

PR xUnit Publish NuGet NuGet Version NuGet Downloads License

A .NET 8 library for generating .xlsx workbooks from a custom XML DSL (urn:excelreport:v1) and runtime data.

Overview

ExcelReportLib converts declarative report definitions into Excel files through a staged pipeline:

  1. Parse XML DSL into AST nodes.
  2. Evaluate expressions and resolve styles/components.
  3. Expand layout primitives (grid, repeat, use, cell) into concrete coordinates.
  4. Build worksheet state (cells, merges, named areas, sheet options).
  5. Render OpenXML workbook streams, including _Issues and _Audit sheets when applicable.

Primary orchestration is handled by ReportGenerator.

Features

  • XML DSL-based report definitions (urn:excelreport:v1)
  • Expression evaluation (@(root...), @(data...), @(vars...))
  • Reusable components via <component> and <use>
  • External component import via <componentImport>
  • Collection expansion via <repeat>
  • Style system with imports, composition, borders, and number formats
  • Named areas and formula placeholder resolution (e.g. #{Detail.Value:Detail.ValueEnd})
  • Worksheet options (freeze panes, grouping, auto filter)
  • OpenXML rendering with diagnostics and generation audit metadata

Architecture

flowchart LR
    A[DSL XML] --> B[DslParser]
    B --> C[Workbook AST]

    C --> D[LayoutEngine]
    E[ExpressionEngine] --> D
    F[StyleResolver] --> D

    D --> G[LayoutPlan]
    G --> H[WorksheetStateBuilder]
    H --> I[WorksheetState]
    I --> J[XlsxRenderer]
    J --> K[.xlsx Stream]

    R[ReportGenerator] -. orchestrates .-> B
    R -. orchestrates .-> D
    R -. orchestrates .-> H
    R -. orchestrates .-> J

Core modules:

  • DSL/DslParser: parsing + optional XSD validation + issue collection
  • ExpressionEngine: expression parsing/evaluation with cache support
  • Styles/StyleResolver: style indexing and precedence composition
  • LayoutEngine: layout expansion, repeat/use expansion, conditional rendering
  • WorksheetState/WorksheetStateBuilder: merge/bounds validation and formula placeholder resolution
  • Renderer/XlsxRenderer: OpenXML output generation
  • ReportGenerator: end-to-end orchestration and phase logging

Installation

Prerequisites

  • .NET SDK 8.0+

Add as a project reference (from source)

dotnet add <your-app>.csproj reference ExcelReport/ExcelReportLib/ExcelReportLib.csproj

Build

dotnet build ExcelReport.sln

Quick Start

1) Define DSL

<workbook xmlns="urn:excelreport:v1">
  <styles>
    <style name="HeaderCell" scope="cell">
      <font bold="true"/>
      <fill color="#F2F2F2"/>
      <border mode="cell" bottom="thin" color="#000000"/>
    </style>
  </styles>

  <sheet name="Summary">
    <cell r="1" c="1" value="@(root.Title)" />

    <grid rows="1" cols="2">
      <cell r="1" c="1" value="Item" />
      <cell r="1" c="2" value="Value" />
    </grid>

    <repeat r="3" c="1" direction="down" from="@(root.Items)" var="it">
      <grid rows="1" cols="2">
        <cell r="1" c="1" value="@(it.Name)" />
        <cell r="1" c="2" value="@(it.Value)" />
      </grid>
    </repeat>
  </sheet>
</workbook>

2) Generate workbook

using ExcelReportLib;

var dsl = File.ReadAllText("report.xml");
var data = new
{
    Title = "Sales Report",
    Items = new[]
    {
        new { Name = "A", Value = 100 },
        new { Name = "B", Value = 200 }
    }
};

var generator = new ReportGenerator();
var result = generator.Generate(dsl, data);

if (result.Succeeded)
{
    File.WriteAllBytes("report.xlsx", result.Output.ToArray());
}
else
{
    foreach (var issue in result.Issues)
    {
        Console.WriteLine($"[{issue.Severity}] {issue.Kind}: {issue.Message}");
    }
}

API Reference Summary

Primary API

  • ReportGenerator
    • Generate(string dsl, object? data, ReportGeneratorOptions? options = null, CancellationToken cancellationToken = default)
    • GenerateFromFile(string dslFilePath, object? data, ReportGeneratorOptions? options = null, CancellationToken cancellationToken = default)
  • ReportGeneratorOptions
    • EnableSchemaValidation
    • TreatExpressionSyntaxErrorAsFatal
    • Logger
    • RenderOptions
  • ReportGeneratorResult
    • Output, Issues, LogEntries, Succeeded, AbortedByFatal, UnhandledException

Advanced/Composable APIs

  • Parsing: DslParser, DslParserOptions, DslParseResult, Issue
  • Expression: IExpressionEngine, ExpressionEngine, ExpressionContext, ExpressionResult
  • Layout: ILayoutEngine, LayoutEngine, LayoutPlan, LayoutSheet, LayoutCell
  • Styles: IStyleResolver, StyleResolver, StylePlan, ResolvedStyle
  • Worksheet state: IWorksheetStateBuilder, WorksheetStateBuilder, WorksheetState, CellState
  • Rendering: IRenderer, XlsxRenderer, RenderOptions, RenderResult
  • Logging: IReportLogger, ReportLogger, LogEntry, LogLevel, ReportPhase

Project Structure

.
├── ExcelReport.sln
├── ExcelReport/
│   ├── ExcelReportLib/
│   │   ├── DSL/
│   │   ├── ExpressionEngine/
│   │   ├── LayoutEngine/
│   │   ├── Styles/
│   │   ├── WorksheetState/
│   │   ├── Renderer/
│   │   └── ReportGenerator.cs
│   └── ExcelReportLib.Tests/
│       ├── DslParserTests.cs
│       ├── LayoutEngineTests.cs
│       ├── RendererTests.cs
│       ├── ReportGeneratorTests.cs
│       └── ...
└── reports/

Testing

Run all tests:

dotnet test ExcelReport.sln

Run only library tests:

dotnet test ExcelReport/ExcelReportLib.Tests/ExcelReportLib.Tests.csproj

Run with coverage collector:

dotnet test ExcelReport/ExcelReportLib.Tests/ExcelReportLib.Tests.csproj --collect:"XPlat Code Coverage"

License

This project is licensed under the MIT License. See LICENSE.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.2.2-pre 87 4/17/2026
2.2.1-pre 89 4/17/2026
2.2.0 91 4/16/2026
2.1.5-pre 86 4/16/2026
2.1.4-pre 101 4/14/2026
2.1.3-pre 97 4/5/2026
2.1.2-pre 90 4/5/2026
2.1.1-pre 89 4/5/2026
2.1.0 103 4/5/2026
2.0.4-pre 85 4/5/2026
2.0.3-pre 87 4/5/2026
2.0.2-pre 89 4/5/2026
2.0.1-pre 89 4/5/2026
2.0.0 119 3/26/2026
1.3.1-pre 101 3/26/2026
1.3.0 103 3/25/2026
1.2.6-pre 103 3/25/2026
1.2.5-pre 102 3/25/2026
1.2.4-pre 107 3/24/2026
1.2.3-pre 102 3/24/2026
Loading failed