Exporting and Printing a Dashboard from Code
Our sample projects and report templates can help you learn the basics of working with our products.A dashboard can be printed or exported straight to the HTTP response — no viewer needed. Each action loads the dashboard and returns it in the chosen format.
Load the dashboard, then respond in a format.
How it works. The prepared dashboard is format-agnostic, so each controller action just picks how to serialize the same document.
Load the dashboard, then respond in a format.
private StiReport GetDashboard()
{
var report = StiReport.CreateNewDashboard();
report.Load(StiNetCoreHelper.MapPath(this, "Dashboards/DashboardChristmas.mrt"));
return report;
}
public IActionResult ExportPdf() => StiNetCoreReportResponse.ResponseAsPdf(GetDashboard());
public IActionResult ExportExcel() => StiNetCoreReportResponse.ResponseAsExcel2007(GetDashboard());
public IActionResult PrintPdf() => StiNetCoreReportResponse.PrintAsPdf(GetDashboard());StiNetCoreReportResponse.ResponseAsPdf/ResponseAsExcel2007/ResponseAsPng— stream the dashboard to the browser in that format.PrintAsPdf/PrintAsHtml— send it straight to the browser's print flow.
How it works. The prepared dashboard is format-agnostic, so each controller action just picks how to serialize the same document.