xtrareports-devexpress-dot-blazor-dot-reporting-dot-dxreportviewer-dot-openreportasync-x28-devexpress-dot-xtrareports-dot-ireport-x29.md
Asynchronously opens the specified report and builds a document for preview.
Namespace : DevExpress.Blazor.Reporting
Assembly : DevExpress.Blazor.Reporting.v25.2.Viewer.dll
NuGet Package : DevExpress.Blazor.Reporting.Viewer
public Task OpenReportAsync(
IReport report
)
Public Function OpenReportAsync(
report As IReport
) As Task
| Name | Type | Description |
|---|---|---|
| report | IReport |
A report to open. You can specify an XtraReport instance or CachedReportSource instance for large documents.
|
| Type | Description |
|---|---|
| Task |
An asynchronous operation that loads a report.
|
The following code uses a custom helper (MyReportProvider) for report name resolution (to instantiate a report by name). The report instance is passed to the OpenReportAsync method. If a name indicates a large report, the CachedReportSource instance is created and passed to the OpenReportAsync method instead.
@using DevExpress.XtraPrinting.Caching;
@using DevExpress.XtraReports.UI;
<DxReportViewer @ref="reportViewer"></DxReportViewer>
@code {
DxReportViewer reportViewer;
string ReportName;
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender) {
XtraReport report = MyReportProvider.GetReport(ReportName);
if (Viewer != null) {
if(ReportName == ReportNames.LargeDatasetName)
await Viewer.OpenReportAsync(
new CachedReportSource(report, new MemoryDocumentStorage()));
else
await Viewer.OpenReportAsync(report);
}
}
}
}
See Also