Setting the Variable Value from Code
Unsere Beispiele der Projekte und Berichtsvorlagen helfen Ihnen, die Grundlagen der Arbeit mit unserer Software zu erlernen.This example demonstrates how to set variable value from code. First, load report template, next, render and export it in PDF:
Auf dem Screenshot unten Sie können das Ergebnis des Beispiel-Codes ansehen:

<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>Auf dem Screenshot unten Sie können das Ergebnis des Beispiel-Codes ansehen:
