When the user exports a report in the viewer, the generated file can be sent back to the server and saved — handled in the onEndExportReport event.

Save the exported file in PHP.
$viewer = new StiViewer();
$viewer->javascript->relativePath = '../';

$viewer->onEndExportReport = function (StiExportEventArgs $args) {
    $reportName = $args->fileName . '.' . $args->fileExtension;
    file_put_contents("../reports/$reportName", base64_decode($args->data));

    return StiResult::getSuccess("Saved to '$reportName'.");
};

$viewer->handler->process();
$viewer->report = $report;

How it works. The export travels from the client viewer to the PHP event, so exported files can be archived on the server automatically.

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.