Using Report Variables in Code
Our sample projects and report templates can help you learn the basics of working with our products.Report variables receive values from the application — text boxes, date pickers, checkboxes — assigned by name before rendering.
Assign variables by name. Load the report, then set each variable through the report indexer:
How it works. Values are assigned before rendering, so the report is generated with exactly the data the user entered in the Avalonia UI.
Assign variables by name. Load the report, then set each variable through the report indexer:
var report = new StiReport();
report.Load(AssetLoader.Open(new Uri("avares://…/Variables.mrt")));
report["Name"] = tbName.Text;
report["Surname"] = tbSurname.Text;
report["Email"] = tbEmail.Text;
report["Sex"] = rbMale.IsChecked.GetValueOrDefault();
report["BirthDay"] = dtBirthDay.SelectedDate.GetValueOrDefault().DateTime;- The indexer
report["Name"]reads and writes report variables by name. - Each value's type matches the variable defined in the template (string, bool, DateTime …).
How it works. Values are assigned before rendering, so the report is generated with exactly the data the user entered in the Avalonia UI.