This example shows how to export the report to the HTML format from code. You need to create the report object of the StiReport type, then load the report template file by calling the loadFile() method. After this, you should render the report by calling the renderAsync() method of the report object:
// 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;
});

For export a report to the HTML format you can use the exportDocumentAsync() function of the StiReport object. As the first argument, you need to specify the callback function that will be called after the export is complete. The second argument indicates the export format. For example, the result is displayed in the DIV container by its Id:
<button id="showHtml" onclick="exportReportHtml()" disabled>Show HTML report</button>
<div id="htmlContainer"></div>
// 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);
}

If you need to save the HTML export result to the file, you can use the StiObject.saveAs() method. This method was added in the Stimulsoft library, you can use it for saving files. The export process will be the same as in the HTML output in a DIV container:
<button id="saveHtml" onclick="saveReportHtml()" disabled>Save HTML report to file</button>
// 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);
}

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

Exporting a Report to HTML

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