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:

Setting the Variable Value from Code

By using this website, you agree to the use of cookies for analytics and personalized content. Cookies store useful information on your computer to help us improve efficiency and usability. For more information, please read the privacy policy and cookie policy.