Exporting a Report from Code
Our sample projects and report templates can help you learn the basics of working with our products.A report can be exported from PHP code to several formats. This example renders a report and exposes buttons that export it to PDF, Excel or HTML.
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.
In the screenshot below you can see the result of the sample code:

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->process();
$report->loadFile('../reports/SimpleList.mrt');
$report->render();
// inside JS-invoked functions:
$report->exportDocument(StiExportFormat::Pdf);
echo $report->getHtml(StiHtmlMode::Scripts);process() / loadFile() / render()— set up, load and render the report on the client.exportDocument(StiExportFormat::Pdf)— exports the rendered document; change theStiExportFormatconstant for Excel, Word, HTML and more.getHtml(StiHtmlMode::Scripts)— emits the scripts that trigger the export in the browser.
exportDocument takes a StiExportFormat value; emitting the resulting scripts triggers the export in the browser. Changing the format constant exports to Excel, Word, HTML and other formats the same way.In the screenshot below you can see the result of the sample code:
