-
Notifications
You must be signed in to change notification settings - Fork 1
/
Exporting a Dashboard from Code.php
86 lines (72 loc) · 2.95 KB
/
Exporting a Dashboard from Code.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
require_once 'vendor/autoload.php';
use Stimulsoft\Enums\StiHtmlMode;
use Stimulsoft\Export\Enums\StiExportFormat;
use Stimulsoft\Report\StiReport;
// Creating a report object
$report = new StiReport();
// Processing the request and, if successful, immediately printing the result
$report->process();
// Loading a dashboard by URL
// This method does not load the report object on the server side, it only generates the necessary JavaScript code
// The dashboard will be loaded into a JavaScript object on the client side
$report->loadFile('reports/Christmas.mrt');
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<title>Exporting a Report from Code</title>
<style>
html, body {
font-family: sans-serif;
}
</style>
<?php
// Rendering the necessary JavaScript code of the dashboard engine
$report->javascript->renderHtml();
?>
<script type="text/javascript">
function exportToPdf() {
<?php
// Calling the dashboard export to the PDF format
// This method does not export the dashboard on the server side, it only generates the necessary JavaScript code
// The dashboard will be exported using a JavaScript engine on the client side
$report->exportDocument(StiExportFormat::Pdf);
// Rendering only the JavaScript code of the dashboard engine
echo $report->getHtml(StiHtmlMode::Scripts);
?>
}
function exportToExcel() {
<?php
// Calling the dashboard export to the Excel format
// This method does not export the dashboard on the server side, it only generates the necessary JavaScript code
// The dashboard will be exported using a JavaScript engine on the client side
$report->exportDocument(StiExportFormat::Excel);
// Rendering only the JavaScript code of the dashboard engine
echo $report->getHtml(StiHtmlMode::Scripts);
?>
}
function exportToHtml() {
<?php
// Calling the dashboard export to the HTML format
// This method does not export the dashboard on the server side, it only generates the necessary JavaScript code
// The dashboard will be exported using a JavaScript engine on the client side
$report->exportDocument(StiExportFormat::Html);
// Rendering only the JavaScript code of the dashboard engine
echo $report->getHtml(StiHtmlMode::Scripts);
?>
}
</script>
</head>
<body>
<h2>Exporting a Dashboard from Code</h2>
<hr>
<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>
</body>
</html>