Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DxReportViewer.OpenReportAsync(IReport) Method

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

Namespace: DevExpress.Blazor.Reporting

Assembly: DevExpress.Blazor.Reporting.v24.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.

Razor
@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