Using Report Variables in Code
Our sample projects and report templates can help you learn the basics of working with our products.Report variables can be assigned from code before rendering — handy for passing application state into a template (Angular).
Set variables in the component, then bind the viewer.
How it works. Values are set on the report before it is bound to
Set variables in the component, then bind the viewer.
export class UsingReportVariablesInCode {
report = new Stimulsoft.Report.StiReport();
constructor() {
this.report.loadFile("Reports/Variables.mrt");
this.report.setVariable("Name", "Andrew");
this.report.setVariable("Sex", true);
this.report.setVariable("BirthDay", Stimulsoft.System.DateTime.fromString("10.10.2010"));
}
}
// template: <sti-viewer [report]="report"></sti-viewer>report.setVariable(name, value)— assign each template variable by name before the viewer renders it.Stimulsoft.System.DateTime.fromString— build a date value forDateTimevariables.
How it works. Values are set on the report before it is bound to
<sti-viewer>, so the rendered document reflects the application's state.