This example shows how to export a dashboard asynchronously. First, you need to load dashboard template:
...
private StiReport GetTemplate()
{
var report = StiReport.CreateNewDashboard();
report.Load("Dashboards\\DashboardChristmas.mrt");
return report;
}
...
Next, use
ExportDocumentAsync()
method to export the dashboard to format you need:
...
private async void buttonPdf_Click(object sender, EventArgs e)
{
saveFileDialog.FileName = Report.ReportName + ".pdf";
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
labelStatus.Text = "Exporting...";
await Report.ExportDocumentAsync(StiExportFormat.Pdf, saveFileDialog.FileName);
labelStatus.Text = "";
}
}
private async void buttonExcel_Click(object sender, EventArgs e)
{
saveFileDialog.FileName = Report.ReportName + ".xlsx";
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
labelStatus.Text = "Exporting...";
await Report.ExportDocumentAsync(StiExportFormat.Excel2007, saveFileDialog.FileName);
labelStatus.Text = "";
}
}
private async void buttonImage_Click(object sender, EventArgs e)
{
saveFileDialog.FileName = Report.ReportName + ".png";
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
labelStatus.Text = "Exporting...";
await Report.ExportDocumentAsync(StiExportFormat.ImagePng, saveFileDialog.FileName);
labelStatus.Text = "";
}
}
...
In the screenshot below you can see the result of the sample code: