This sample project shows how to export and print the dashboard from code without using the viewer.

For this action, it is enough to use the special StiReportResponse class. This class implements the static methods for dashboard exporting and printing that take the input of all the necessary parameters for configuration. For example, add a link for print and two links for various export formats:
<div align="center">
    <button @onclick="ExportDashboardAsHTML">Export as HTML</button>   <button @onclick="ExportDashboardAsPDF">Export as PDF</button>   <button @onclick="PrintDashboard">Print</button>
    <br /><br />
    <input id="responseAsFile" type="checkbox" @bind="responseAsFile"><label for="responseAsFile">Response as File</label>
    <br /><br />
    <p>@message</p>
</div>

Now we need to determine the actions that will be invoked when clicking on links. For printing we will use the PrintDashboard method:
private async Task PrintDashboard()
{
	// Create empty dashboard object
	var report = StiReport.CreateNewDashboard();

	// Load dashboard template
	var reportBytes = await Http.GetByteArrayAsync("Dashboards/DashboardChristmas.mrt");
	report.Load(reportBytes);

	// Print dashboard
	StiReportResponse.PrintAsPdf(report);

	message = new MarkupString("The dashboard printed");
}

For exporting, we will use two action methods - ExportDashboardAsPDF and ExportDashboardAsHTML. These export formats are taken for example. Also, the methods of exporting a dashboard (and printing) can take, as input, export settings and other necessary parameters:
private async Task ExportDashboardAsHTML()
{
	// Create empty dashboard object
	var report = StiReport.CreateNewDashboard();

	// Load dashboard template
	var reportBytes = await Http.GetByteArrayAsync("Dashboards/DashboardChristmas.mrt");
	report.Load(reportBytes);

	StiReportResponse.ResponseAsHtml(report, responseAsFile);
	message = new MarkupString("Export to HTML is completed.");
}

private async Task ExportDashboardAsPDF()
{
	// Create empty dashboard object
	var report = StiReport.CreateNewDashboard();

	// Load dashboard template
	var reportBytes = await Http.GetByteArrayAsync("Dashboards/DashboardChristmas.mrt");
	report.Load(reportBytes);

	StiReportResponse.ResponseAsPdf(report, responseAsFile);
	message = new MarkupString("Export to PDF is completed.");
}

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

Exporting and Printing a Dashboard from Code

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