Skip to content

DevExpress-Examples/maui-generate-data-bound-report

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DevExpress Reporting for .NET MAUI - Generate and Display a Data-Bound Report

This example uses DevExpress PDF Viewer for .NET MAUI to display a data-bound report in a mobile app.

You can adjust this example to use any existing report. In this repository, the ReportLibrary folder contains the data source and the report layout definition. We constructed the report with the help of the DevExpress Report Designer and named the report class XtraReportInstance. The code below creates this object to generate a report document.

NOTE: To use Reporting APIs in a .NET MAUI project, you need a license that includes DevExpress Reporting.

DevExpress Reporting for .NET MAUI - Generate Bound-Data Report

Included Controls and Their Properties

Implementation Details

  1. Define the CreateTableReportAsync() function that creates a new report. Use the XtraReportInstance() constructor to generate a report instance. Call the CreateDocument() method to create a document from the report:

    public async Task<XtraReport> CreateTableReportAsync() {
        XtraReportInstance report = null;
        await Task.Run(() =>
        {
            report = new XtraReportInstance() { Name = "Sample" };
            report.CreateDocument();
        });
        return report;
    }
  2. When the page loads, call the CreateTableReportAsync() function to generate a new report:

    private async void ContentPage_Loaded(object sender, EventArgs e) {
        XtraReport report = await CreateTableReportAsync();
        // ...
    }
  3. Call the ExportToPdf(resultFile) method to convert the report to PDF:

    private async void ContentPage_Loaded(object sender, EventArgs e) {
        // ...
        string resultFile = Path.Combine(FileSystem.Current.AppDataDirectory, report.Name + ".pdf");
        report.ExportToPdf(resultFile);
        // ...    
    }
  4. Use the PdfViewer.DocumentSource property to open the report in the PDF Viewer control:

    private async void ContentPage_Loaded(object sender, EventArgs e) {
        // ...
        pdfViewer.DocumentSource = PdfDocumentSource.FromFile(resultFile);
        // ...    
    }

Files to Review

Documentation

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

About

This example uses DevExpress PDF Viewer for .NET MAUI to display a data-bound report in a mobile app.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 6

Languages