【Stimulsoft Reports Flex教程】在代码中使用报表变量
此示例显示如何从代码中设置报表变量的值。所有变量都位于StiReport对象的dictionary.variables集合中。要获取或设置变量的值,可以使用StiVariable对象的valueObject属性:
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(); }
下面的屏幕截图中,您可以看到示例代码的结果。