Exporting a Report from Code on the Server-Side
Our sample projects and report templates can help you learn the basics of working with our products.Server-side rendering can be followed by a server-side export. This example renders a report with the Node.js engine and exports it to text.
Exporting the document. Load and render the report, configure the requested export format, and deliver the generated bytes as a file, stream, or web response.
With the Node.js engine,
Exporting the document. Load and render the report, configure the requested export format, and deliver the generated bytes as a file, stream, or web response.
$report = new StiReport();
$report->engine = StiEngineType::ServerNodeJS;
$report->process();
$report->loadFile('reports/SimpleList.mrt');
$report->render();
$result = $report->exportDocument(StiExportFormat::Text);
if ($result !== false) echo "<pre>$result</pre>";engine = StiEngineType::ServerNodeJS— renders headlessly with the Node.js engine, no browser required.render()— builds the document on the server.exportDocument(StiExportFormat::Text)— returns the exported data on the server for saving or sending.
With the Node.js engine,
exportDocument returns the exported data on the server, so you can generate PDFs, spreadsheets or text files in a background job without any client.