This example shows how to render and export reports asynchronously. First, specify the path to the reports:
...
public FormMain()
{
InitializeComponent();
labelLoad.Text = "Loading... ";
Report = new StiReport();
Report.Load("..\\MasterDetail.mrt");
labelLoad.Text += "OK";
}
...
Next, use
RenderAsync()
method to render the report:
...
private async void buttonRender_Click(object sender, EventArgs e)
{
labelRender.Text = "Rendering... ";
await Report.CompileAsync(); // if compilation is needed
await Report.RenderAsync();
labelRender.Text += "OK";
}
...
After that, use
ExportDocumentAsync()
method to export the report:
...
private async void buttonExport_Click(object sender, EventArgs e)
{
saveFileDialog.FileName = Report.ReportName + ".pdf";
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
labelExport.Text = "Exporting... ";
await Report.ExportDocumentAsync(StiExportFormat.Pdf, saveFileDialog.FileName);
labelExport.Text += "OK";
}
}
...
На скриншоте ниже Вы можете увидеть результат выполнения данного кода: