Skip to content
Report-Designer

Tutorial

From a blank project to a PDF

Two parts, about 20 minutes. The first uses the desktop designer and the sample project in the repository. The second needs an ASP.NET Core or MVC 5 app.

Design your first report

Install the designer, start a check voucher from a template, connect it to your data, and preview it.

  1. Install the designer

    Run ReportDesigner-win-Setup.exe from the download page. It installs for your Windows account and needs no admin rights. It adds Start menu and desktop shortcuts and installs WebView2 if needed.

    The installed designer checks for updates after it starts. Click the update button in the footer to download an available version. Then click Restart to update or close the designer to install it.

    If the installer is unavailable, build from source. See Install the designer for the requirements.

    npm.cmd --prefix src/designer-ui install
    npm.cmd --prefix src/designer-ui run build
    dotnet run --project src/ReportDesigner.App
  2. Open the sample project

    A report project is one folder for a company’s reports, templates and assets, with a company profile every report can print.

    In the title bar, open the Project menu and choose Open project…. Pick samples/Reports from the repository. The menu shows the project name, and the sidebar lists its three reports. The company card at the bottom opens Project settings, where you can edit the name, address, TIN and logo for the project.

    To reopen a project, look under Recent projects in the same menu. To reopen an individual report, use the Open recent arrow beside Open.

    You can follow the tutorial with sample data. To use your own stored procedure, set up a connection first.

  3. Start from a template

    Click New report in the title bar. The gallery shows a blank page and templates with your company profile.

    Pick Check voucher and click Next: match fields.

    New report gallery with template categories on the left and layout cards on the right

  4. Match the fields to your stored procedure

    In Match fields: Check voucher, choose a Connection and enter or select Your stored procedure. Click Match columns. The designer suggests matches such as VoucherNo to voucher_no and flags missing columns when it has the list of columns for the data set.

    To match fields for the voucher lines, fill in any parameter values and click Read all result sets when it appears. The designer runs the procedure once in a transaction and rolls it back.

    Type a replacement column name if needed. Leave a name blank to keep the template’s name. To use the template’s sample data, you can skip the connection and click Create report directly. To try the sample database, open the project’s existing Check voucher report. Its layout matches dbo.rpt_CheckVouchers, which omits the template’s PayeeTin field.

    Check voucher field matching with connection and procedure controls above the template fields

  5. Map fields after changing the data source

    To switch an existing report to a different stored procedure, open Design and click Change in the Data source panel on the left. Click Choose if the report has no procedure yet. Select the procedure and click Use this procedure. If the new procedure leaves out fields or data sets the report uses, the designer opens Map fields.

    Review where each field is used and choose a replacement column, such as BPName for Payee. Click Map fields in the dialog to update those references. You can reopen it from the Data source panel or from an unknown-field error in Preview. See Map fields after changing the data source for procedures that return a different set of rows.

  6. Lay out the page

    Open Design to lay out the report. The canvas shows its bands, such as Report header and Details. The details band normally repeats for each main row.

    • On the left, drag a field from Data fields onto a band, or use Insert to add text, lines, boxes, images, barcodes and tables.
    • Objects snap to the grid and to each other’s edges. Shift-click or drag a box to select several, then align or distribute them.
    • The Properties panel on the right edits the selected object, table cell or band. Clear the selection to set paper size, margins, copies and the pre-printed form scan.

    Check voucher in Design with the project and fields on the left, the voucher in the center and properties on the right

  7. Group rows with a table

    To group the check voucher’s lines, right-click a cell in its table and choose Add group. Choose a field such as AccountCode. A group footer cell with Sum({Debit}) adds up the debits for that group. The same expression in the table footer adds up the debits for the whole table.

    To make a table from scratch, click Table under Insert. In Insert table, choose the data set and columns. For a single list of all rows, choose Report header under Place in. Use Group by to add groups, then click Insert table.

    Sales by customer in Design with a table showing group headers, subtotal rows and a total row

  8. Write a formula

    Open the Formulas tab and click the plus button next to Formulas on the left. Set Name to AmountWithVat and enter the calculation in Expression. Use C# expressions with Crystal-style references.

    • {Amount} is a column, {?FromDate} a parameter, {@AmountWithVat} another formula and {#GrandTotal} a running total.
    • Type { for suggestions. Errors show as you type. Click Check formulas to check them all.

    For example, {Amount} * 1.12m adds 12% VAT, and ToWords({Amount}) prints an amount in words for a check.

    To show the formula on the report, return to Design and drag it from Formulas on the left onto a band.

    Formulas tab with AmountWithVat selected, its expression in the center and Functions and Special values on the right

  9. Preview and save

    Open the Preview tab. It runs when the tab opens or you change the data mode. Choose Sample data to use the template’s rows. If the report has a connection and procedure, choose Database, enter the parameters and click Run report. The preview uses the same page layout as the PDF.

    For a new report, click Save in the title bar. The file dialog starts in the project’s reports folder. If you opened the existing sample report, press Ctrl+Shift+S to save a copy. Choose a new name such as my-check-voucher.report.json.

    Preview tab with the sample data controls above the rendered check voucher and its account lines

Render from your app

Add the engine to an ASP.NET Core or MVC 5 app and return the report as a PDF.

  1. Add the packages

    The packages are on GitHub Packages, which needs a token even to read. Create a personal access token (classic) with the read:packages scope, then add the feed once per machine:

    dotnet nuget add source "https://nuget.pkg.github.com/racherim/index.json" --name report-designer --username <your GitHub user> --password <token>

    For ASP.NET Core:

    dotnet add package ReportDesigner.AspNetCore

    For ASP.NET MVC 5 on .NET Framework 4.8, add ReportDesigner.Runtime instead.

  2. Point your app at the reports

    In Program.cs, register the engine with your report project and connection strings. Report files only name a connection, such as Sales. Your app maps that name to its own configuration.

    builder.Services.AddReportDesigner(options =>
    {
        options.ProjectPath = "Reports";
        options.Connections["Sales"] = builder.Configuration.GetConnectionString("Sales")!;
    });

    Reports are read on every render, so copying in a new version takes effect on the next print.

    For MySQL or MariaDB, register the connection string the same way. If the string could also be read as SQL Server, replace the connection assignment inside AddReportDesigner with this line. DatabaseConnections is in ReportDesigner.Data.

    options.Connections["Sales"] = DatabaseConnections.MySql(builder.Configuration.GetConnectionString("Sales")!);

    See Connect to data for connection options.

  3. Return a PDF from a controller

    Ask for IReportService and render by report name. With parameters only, the report runs its own stored procedure:

    public sealed class InvoicesController(IReportService reports) : ControllerBase
    {
        [HttpGet("reports/sales")]
        public async Task<IActionResult> Sales(DateTime from, DateTime to, CancellationToken ct)
        {
            var pdf = await reports.RenderAsync("sales-summary", new { FromDate = from, ToDate = to }, ReportFormat.Pdf, ct);
            return File(pdf, "application/pdf");
        }
    }

    To render rows you already have, such as an EF Core query, pass them before the parameters: reports.RenderAsync("sales-summary", rows, parameters, ReportFormat.Pdf, ct).

    For Excel or Word, pass ReportFormat.Excel or ReportFormat.Word. ReportFormats.ContentType and ReportFormats.FileExtension give the content type and file extension.

  4. Do the same in MVC 5

    Configure ReportHost once in Global.asax, then call it from any controller:

    // Global.asax.cs, Application_Start
    ReportHost.Configure(o =>
    {
        o.ProjectPath = Server.MapPath("~/Reports");
        o.Connections["Sales"] = ConfigurationManager.ConnectionStrings["Sales"].ConnectionString;
    });
    
    // Controller
    public async Task<ActionResult> Sales(DateTime from, DateTime to)
    {
        var pdf = await ReportHost.Reports.RenderAsync("sales-summary", new { FromDate = from, ToDate = to });
        return File(pdf, "application/pdf");
    }

    Keep AutoGenerateBindingRedirects on so Web.config gets the redirects for the engine’s dependencies.

  5. Optional: render on a report server

    The report server hosts report projects and renders them over HTTP. Apps render through the server using its URL, a project name and an API key.

    Make a key for each app. The command prints the key for the app and a hash for the server’s configuration:

    ReportDesigner.Server new-key "Payroll app"

    Then switch the app over with configuration. Controllers keep calling IReportService:

    // "ReportServer": { "Url": "https://reports.local", "Project": "accounting", "ApiKey": "..." }
    builder.Services.AddReportDesigner(o => builder.Configuration.GetSection("ReportServer").Bind(o.Server));

    The server writes render requests to its audit log. See Install the report server to deploy it as a Windows service or under IIS, and Scheduled reports by email to send reports on a schedule.

  6. Optional: print straight to a user's PC

    Install the print agent on the user’s Windows PC and point it at the report server. Set its queue, which usually matches the PC name. Add "PrintQueues": ["ACCT-PC-01"] to the agent’s API key entry on the server so it can collect jobs from that queue.

    From the app, call PrintAsync on a ReportServerClient to send the report to the queue. Pass both the main voucher rows and the lines data set.

    var data = ReportData.FromObjects(vouchers).With("lines", lines);
    var jobId = await server.PrintAsync("check-voucher", data, parameters: null, queue: "ACCT-PC-01", copies: 2);

    The agent runs in the user’s session and prints without a dialog. See Printing straight to users’ PCs for agent settings and job status.