-
Notifications
You must be signed in to change notification settings - Fork 3
/
Exporting a Report to HTML.html
55 lines (47 loc) · 1.92 KB
/
Exporting a Report to HTML.html
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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Exporting a Report to HTML</title>
<!-- Stimulsoft Reports.JS -->
<script src="../scripts/stimulsoft.reports.js" type="text/javascript"></script>
</head>
<body>
Exporting a Report to HTML
<br><br>
<script type="text/javascript">
// Create a new report instance
var report = new Stimulsoft.Report.StiReport();
// Load report from url
report.loadFile("../reports/SimpleList.mrt");
// Render report
report.renderAsync(function () {
document.getElementById("showHtml").disabled = false;
document.getElementById("saveHtml").disabled = false;
});
// Export report to HTML format and show it
function exportReportHtml() {
// Export to HTML
report.exportDocumentAsync(function (htmlString) {
// Write HTML text to DIV element.
var container = document.getElementById("htmlContainer");
container.innerHTML = htmlString;
}, Stimulsoft.Report.StiExportFormat.Html);
}
// Export report to HTML format and save to file
function saveReportHtml() {
// Export to HTML
var htmlString = report.exportDocumentAsync(function (htmlString) {
// Get report file name
var fileName = report.reportAlias;
// Save data to file
Stimulsoft.System.StiObject.saveAs(htmlString, fileName + ".html", "text/html;charset=utf-8");
}, Stimulsoft.Report.StiExportFormat.Html);
}
</script>
<button id="showHtml" onclick="exportReportHtml()" disabled>Show HTML report</button><br>
<button id="saveHtml" onclick="saveReportHtml()" disabled>Save HTML report to file</button><br>
<br><br>
<div id="htmlContainer"></div>
</body>
</html>