Skip to main content
All docs
V23.2

DxReportViewer.OpenReportAsync(IReport) Method

Asynchronously opens the specified report and builds a document for preview.

Namespace: DevExpress.Blazor.Reporting

Assembly: DevExpress.Blazor.Reporting.v23.2.Viewer.dll

NuGet Package: DevExpress.Blazor.Reporting.Viewer

Declaration

public Task OpenReportAsync(
    IReport report
)

Parameters

Name Type Description
report IReport

A report to open. You can specify an XtraReport instance or CachedReportSource instance for large documents.

Returns

Type Description
Task

An asynchronous operation that loads a report.

Remarks

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