Changing Report Properties on the Server-Side
Our sample projects and report templates can help you learn the basics of working with our products.A report's template is JSON, so you can modify its properties on the server before rendering.
Code overview. Load or create the report, resolve the target component or option, apply the requested properties, and render the updated result.
Because the template is plain JSON, you can decode it, change any property (here the alias, calculation mode and a variable), and load the modified object — a flexible way to adjust reports dynamically on the server.
Code overview. Load or create the report, resolve the target component or option, apply the requested properties, and render the updated result.
$reportJson = json_decode(file_get_contents('../reports/Variables.mrt'));
$reportJson->ReportAlias = 'Report Alias from Server-Side';
$reportJson->CalculationMode = 'Interpretation';
$reportJson->Dictionary->Variables->{'0'}->Value = 'Value from Server-Side';
$report->load($reportJson);
$report->render();json_decode(file_get_contents(...))— reads the report template, which is plain JSON, into an object.$reportJson->ReportAlias / CalculationMode— change any report property directly on the JSON object.Dictionary->Variables->{'0'}->Value— edits a variable's value inside the template.$report->load($reportJson)— loads the modified object back into the report before rendering.
Because the template is plain JSON, you can decode it, change any property (here the alias, calculation mode and a variable), and load the modified object — a flexible way to adjust reports dynamically on the server.