A zero-dependency fluent API for generating self-contained HTML reports with tables, SVG charts, KPI cards, progress bars, and more. No JavaScript, no external CSS — just clean HTML you can open in any browser, email, or print to PDF.
$ dotnet add package CDS.FluentHtmlReportsA zero-dependency .NET library for generating self-contained HTML reports using a fluent API. No JavaScript, no external CSS, no build tools — just clean HTML you can open in any browser, email as an attachment, or print to PDF.
Sometimes you need to produce a professional-looking report from C# without pulling in a heavyweight reporting framework, a headless browser, or a JavaScript bundler. CDS.FluentHtmlReports generates a single .html file that:
dotnet add package CDS.FluentHtmlReports
Targets: .NET 8 (LTS) and .NET 10+
using CDS.FluentHtmlReports;
var teamMembers = new[]
{
new { Name = "Alice Johnson", Role = "Backend", TasksCompleted = 23, Status = "Active" },
new { Name = "Bob Smith", Role = "Frontend", TasksCompleted = 19, Status = "Active" },
new { Name = "Carol White", Role = "QA", TasksCompleted = 31, Status = "Active" }
};
string html = Generator
.Create("Weekly Team Report")
.AddParagraph("Here's a quick overview of this week's progress for the development team.")
.AddLabelValueRow([
("Week Ending", DateTime.Now.ToString("MMM dd, yyyy")),
("Team", "Engineering"),
("Sprint", "Sprint 24")
])
.AddLine()
.AddHeading("Team Summary")
.AddKpiCards([
("Total Tasks", "73"),
("Completed", "68"),
("In Progress", "5"),
("Success Rate", "93%")
])
.AddLine()
.AddHeading("Team Members")
.AddTable(TableFixedHeader.Header, teamMembers)
.AddLine()
.AddHeading("Task Completion by Role")
.AddVerticalBarChart("Tasks Completed This Week", [
("Backend", 23),
("Frontend", 19),
("QA", 31)
])
.AddLine()
.AddAlert(AlertLevel.Success, "All sprint goals achieved! Great work team! 🎉")
.AddFooter("Generated with CDS.FluentHtmlReports — {timestamp}")
.Generate();
File.WriteAllText("report.html", html);That's it — one fluent chain produces a complete, styled HTML document.
The code above generates a professional HTML report. Here's a preview of the output:

The actual HTML includes:
ConsoleTest...
| Method | Description |
|---|---|
AddHeading(title, level) | Headings H1–H6 (defaults to H2) |
AddParagraph(text) | Paragraph block |
AddMetadata(label, value) | Bold label / value line |
AddLabelValueRow(pairs) | Inline label/value pairs on one row |
AddUnorderedList(items) | Bullet list |
AddOrderedList(items) | Numbered list |
AddAlert(level, message) | Styled callout box (Info, Success, Warning, Error) |
AddCodeBlock(code, language) | Preformatted code block |
AddBadge(text, color) | Small colored label |
AddLink(text, url) | Hyperlink |
AddDefinitionList(items) | Term/definition pairs |
AddProgressBar(label, value) | Auto-colored progress bar |
AddKpiCards(cards) | Row of summary metric cards |
AddLine(lineType) | Separator line (Solid, Dashed, Dotted, Blank) |
AddImage(bytes, mime) | Base64-embedded image |
AddImageFromFile(path) | Image from file path |
AddHtml(content) | Raw HTML insertion |
AddFooter(text) | Footer with optional {timestamp} token |
AddPageBreak() | Page break for print/PDF |
| Method | Description |
|---|---|
AddTable(header, data) | Auto-generates columns from object properties |
AddTable(header, data, cellFormat) | Conditional cell coloring via callback |
AddTable(header, data, summaryColumns) | Summary row (Sum, Average, Min, Max, Count) |
AddKeyValueTable(items) | Simple two-column key/value table |
Header modes: TableFixedHeader.None, .Header, .FirstColumn, .Both
All charts render as inline SVG — no JavaScript, no external images.
| Method | Description |
|---|---|
AddVerticalBarChart(title, data) | Vertical bars with auto or explicit colors |
AddHorizontalBarChart(title, data) | Horizontal bars with auto or explicit colors |
AddPieChart(title, data) | Pie chart with legend |
AddDonutChart(title, data) | Donut chart with legend |
AddLineChart(title, data) | Single-series line chart |
AddLineChart(title, series) | Multi-series line chart |
| Method | Description |
|---|---|
BeginColumns() / EndColumns() | Two-column CSS flexbox layout |
BeginColumn() / EndColumn() | Individual column within a layout |
BeginCollapsible(title) / EndCollapsible() | HTML5 collapsible section |
// Option 1: Pass an options object
.WithOptions(new ReportOptions
{
ChartWidthPercent = 75,
ChartHeight = 300,
ChartAlignment = ChartAlignment.Center
})
// Option 2: Configure via lambda
.WithOptions(o => o.ChartWidthPercent = 60)| Property | Default | Description |
|---|---|---|
ChartWidthPercent | 100 | Chart width as percentage of container (1–100) |
ChartHeight | 280 | Chart height in SVG units |
ChartAlignment | Left | Chart alignment: Left, Center, Right |
Generator.Create("Title") — starts a new HTML document with embedded CSS.Add*() methods — each appends HTML to an internal StringBuilder.Generate() — closes the document and returns the complete HTML stringThe output is a single self-contained HTML file with:
@media print rulesThere are no dependencies beyond the .NET Base Class Library.
Generator Public fluent facade — the only class consumers interact with
├── TextRenderer Headings, paragraphs, lists, alerts, layout, etc.
├── TableRenderer Reflection-based table generation
├── ChartRenderer SVG chart rendering (bar, pie, donut, line)
└── HtmlHelpers Shared HTML encoding utility
All renderers are internal — the public API surface is just Generator, ReportOptions, and a handful of enums.
The ConsoleTest project generates a suite of demo reports:
cd ConsoleTest
dotnet run
This creates several .html files in your Downloads folder and opens the index in your browser. The demos cover every feature and serve as living documentation.
dotnet build
dotnet pack -c Release
The .nupkg will be in CDS.FluentHtmlReports/bin/Release/.
MIT © 2026 Carpe Diem Systems