This example demonstrates how to set variable value from code. First, load report template, next, render and export it in PDF:
<script type="text/javascript">
// Create a new report instance
var report = new Stimulsoft.Report.StiReport();
// Load report
report.loadFile("../reports/ReportWithVariable.mrt");
// Get variable by name
var variable = report.dictionary.variables.getByName("Variable1");
// Set variable value
variable.value = "test";
// Render report
report.renderAsync(function () {
// Export report to HTML string
report.exportDocumentAsync(function (htmlString) {
// Show the report
var container = document.getElementById("reportContainer");
container.innerHTML = htmlString;
}, Stimulsoft.Report.StiExportFormat.Html);
});
</script>
In the screenshot below you can see the result of the sample code: