Using Report Variables in Code

This example shows how to set values of the report variables from code. All variables are located in the dictionary.variables collection of the StiReport object. To get or set the value of the variable, you can use the valueObject property of the StiVariable object:

private function onShowReport1Click(): void
{
// Create new report object
var report: StiReport = new StiReport();
// Load report from XML string
report.loadReportFromString(reportString);
// Change the variables values
for each (var variable: StiVariable in report.dictionary.variables)
{
if (variable.name == "VariableString") variable.valueObject = "String text, variant one";
if (variable.name == "VariableNumber") variable.valueObject = 1;
if (variable.name == "VariableBoolean") variable.valueObject = true;
}
// Show report in Viewer dialog window
report.showDialog();
}


In the screenshot below you can see the result of the sample code.

Using Report Variables in Code