Report setup

Benevia.Core.Reports.Blazor has the report components: ReportSelector, ReportViewerHost, and ReportList, which opens the report designer. Reports run in the browser with Stimulsoft Reports.JS. Its scripts load the first time someone opens a report: about 2 MB for the viewer and 6.5 MB for the designer.

Register

Reference the package from the app and from any library that uses the report components:

<PackageReference Include="Benevia.Core.Reports.Blazor" Version="..." />

Register the services with your license key:

builder.Services.AddCoreReportsBlazor(options =>
    options.LicenseKey = builder.Configuration["Stimulsoft:LicenseKey"]);

Without a key, reports show a trial watermark. The browser receives the key, so keep it in configuration, not in code.

Stimulsoft scripts

Stimulsoft's license does not let a package include its scripts, so the app's build downloads them from npm into obj/. Blazor WebAssembly apps get them automatically. A Blazor Server app turns them on in the project that serves the app:

<PropertyGroup>
  <BeneviaReportScripts>true</BeneviaReportScripts>
</PropertyGroup>

The first build needs access to registry.npmjs.org.

Optional, for a progressive web app: the service worker downloads every static file when the app installs, including these scripts. To load them only when a report opens, leave them out:

const offlineAssetsExclude = [ /^service-worker\.js$/, /^stimulsoft-reports-js\// ];

Fonts

A PDF includes only the fonts the engine has loaded. Register a font file for each font a template uses that is not embedded in the template:

options.Fonts.Add(new ReportFont("fonts/micrenc.ttf", "MICR Encoding"));

The URL is relative to the app's base address.

Templates

Templates are Stimulsoft .mrt files, stored as JSON. Reports.JS cannot read row indexing such as Payment.Rows[0]["Amount"], so the viewer changes it to Payment.GetData("Amount", 0). Use GetData in new templates.

PDF export

See PDF export.