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 StiNetCoreReportResponse 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 three links for various export formats:
<div class="row">
	<div class="col-md-4">
		<h2>Print to PDF</h2>
		<p>@Html.ActionLink("Print", "PrintPdf")</p>
	</div>
</div>
<hr />
<div class="row">
	<div class="col-md-4">
		<h2>Export to PDF</h2>
		<p>@Html.ActionLink("Export", "ExportPdf")</p>
	</div>
	<div class="col-md-4">
		<h2>Export to Excel</h2>
		<p>@Html.ActionLink("Export", "ExportExcel")</p>
	</div>
	<div class="col-md-4">
		<h2>Export to Image</h2>
		<p>@Html.ActionLink("Export", "ExportImage")</p>
	</div>
</div>

To get the dashboard, the GetDashboard() method was used. This method creates the new dashboard object and loads the dashboard template from the file:
private StiReport GetDashboard()
{
	var reportPath = StiNetCoreHelper.MapPath(this, "Dashboards/DashboardChristmas.mrt");
	var report = StiReport.CreateNewDashboard();
	report.Load(reportPath);

	return report;
}

Now we need to determine the actions that will be invoked when clicking on links. For printing we will use the PrintPdf method:
public IActionResult PrintPdf()
{
	var report = this.GetDashboard();
	return StiNetCoreReportResponse.PrintAsPdf(report);
}

For exporting, we will use three action methods - ExportPdf, ExportExcel, and ExportImage. 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:
public IActionResult ExportPdf()
{
	var report = this.GetDashboard();
	return StiNetCoreReportResponse.ResponseAsPdf(report);
}

public IActionResult ExportExcel()
{
	var report = this.GetDashboard();
	return StiNetCoreReportResponse.ResponseAsExcel2007(report);
}

public IActionResult ExportImage()
{
	var report = this.GetDashboard();
	return StiNetCoreReportResponse.ResponseAsPng(report);
}

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

Exporting and Printing a Dashboard from Code

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