This example shows how to export a dashboard from code in Stimulsoft PHP. First, include the necessary libraries:
<?php
require_once '../vendor/autoload.php';

use Stimulsoft\Enums\StiHtmlMode;
use Stimulsoft\Export\Enums\StiExportFormat;
use Stimulsoft\Report\StiReport;
?>

Create a dashboard object and set JavaScript options:
$report = new StiReport();
$report->javascript->relativePath = '../';

Process the request using process():
$report->process();

Load the dashboard template using loadFile():
$report->loadFile('../reports/Christmas.mrt');

Render the necessary JavaScript code for the dashboard engine:
$report->javascript->renderHtml();

Define JavaScript functions for exporting the dashboard in different formats. Each function calls the exportDocument() method and then renders only the scripts with getHtml(StiHtmlMode::Scripts):
<script type="text/javascript">

function exportToPdf() {
    <?php
    $report->exportDocument(StiExportFormat::Pdf);
    echo $report->getHtml(StiHtmlMode::Scripts);
    ?>
}

function exportToExcel() {
    <?php
    $report->exportDocument(StiExportFormat::Excel);
    echo $report->getHtml(StiHtmlMode::Scripts);
    ?>
}

function exportToHtml() {
    <?php
    $report->exportDocument(StiExportFormat::Html);
    echo $report->getHtml(StiHtmlMode::Scripts);
    ?>
}
</script>

Finally, create buttons in the HTML body that call the corresponding export functions:
<button onclick="exportToPdf();">Export Dashboard to PDF</button>
<br><br>
<button onclick="exportToExcel();">Export Dashboard to Excel</button>
<br><br>
<button onclick="exportToHtml();">Export Dashboard to HTML</button>

На скриншоте ниже Вы можете увидеть результат выполнения данного кода:

Exporting a Dashboard from Code

Используя этот сайт, вы соглашаетесь на использование файлов Cookie для аналитики и персонализированного контента. Файлы Cookie хранят полезную информацию на вашем компьютере, чтобы помочь нам повысить эффективность и удобство использования. Для получения дополнительной информации, пожалуйста, прочтите Конфиденциальность и Использование Cookie.