Quick Start

Create your first Wordize report with a small template, a C# data model, and ReportBuilder.
What is this page about?

This page walks through a complete reporting flow with a compact example.

You will define a template, create a booking object, and build a final document by calling Wordize.Reporting.ReportBuilder.

Let’s consider a typical Reporting scenario using a travel booking summary as an example, as it includes a mix of single values, repeated items, dates, and optional fields.

A similar principle applies to invoices, inventory summaries, schedules, and other document types.

Create a Template

Create a template document with ordinary content and reporting tags:

Booking reference: <<[booking.Reference]>>
Primary traveler: <<[booking.PrimaryTraveler]>>
Departure date: <<[booking.DepartureDate]:"dd MMM yyyy">>

Travelers
<<foreach [traveler in booking.Travelers]>>- <<[traveler.FullName]>> (seat: <<[traveler.Seat ?? "pending"]>>)
<</foreach>>

Total amount: <<[booking.TotalAmount]:"0.00">> USD

Use C# Data Model

Use the shared sample model and sample data setup from Shared Sample Model and Data.

Build a Report

Build a report using the created template and data model:

using System.Text;
using Wordize;
using Wordize.Loading;
using Wordize.Reporting;

string template =
    "Booking reference: <<[booking.Reference]>>\n" +
    "Primary traveler: <<[booking.PrimaryTraveler]>>\n" +
    "Departure date: <<[booking.DepartureDate]:\"dd MMM yyyy\">>\n\n" +
    "Travelers\n" +
    "<<foreach [traveler in booking.Travelers]>>- <<[traveler.FullName]>> (seat: <<[traveler.Seat ?? \"pending\"]>>)\n<</foreach>>\n" +
    "Total amount: <<[booking.TotalAmount]:\"0.00\">> USD";

Booking booking = new Booking
{
    Reference = "BK-48291",
    PrimaryTraveler = "Avery Chen",
    DepartureDate = new DateTime(2026, 6, 14),
    TotalAmount = 1840.50m,
    Travelers = new List<Traveler>
    {
        new Traveler { FullName = "Avery Chen", Seat = "12A" },
        new Traveler { FullName = "Noah Patel", Seat = null }
    }
};

// Load template and save output to stream. You can use files as input and output.
using MemoryStream input = new MemoryStream(Encoding.UTF8.GetBytes(template));
using MemoryStream output = new MemoryStream();

ReportBuilder.BuildReport(
    input,
    output,
    SaveFormat.Docx,
    booking,
    "booking");

File.WriteAllBytes(@"C:\Temp\out.docx", output.ToArray());

Alternatively you can use fluent API:

...
using MemoryStream input = new MemoryStream(Encoding.UTF8.GetBytes(template));

ReportBuilderContext context = new ReportBuilderContext();
context.DataSources.Add(booking, "booking");

ReportBuilder.Create(context)
    .From(input)
    .To(@"C:\Temp\out.docx")
    .Execute();

Expected Output

When the template is processed, the final document contains content similar to the following:

Booking reference: BK-48291
Primary traveler: Avery Chen
Departure date: 14 Jun 2026

Travelers
- Avery Chen (seat: 12A)
- Noah Patel (seat: pending)

Total amount: 1840.50 USD

What Happened

  1. <<[booking.Reference]>> inserted a scalar value
  2. <<foreach [traveler in booking.Travelers]>> repeated the bullet line for each traveler
  3. traveler.Seat ?? "pending" handled a nullable value without extra template branches
  4. The date and amount were formatted where they were displayed
Important to note:
For production templates, keep complex calculations in your application code when possible. Templates stay easier to review when expressions focus on presentation rather than business rules.

Next Steps

After the first report works, expand the template gradually:

  • Add conditional sections for optional details such as loyalty status or special assistance
  • Introduce nested loops for itinerary segments or room bookings
  • Move JSON or XML parsing into Wordize data-source classes if your data starts outside .NET objects