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.
-
Define the
CreateTableReportAsync()
function that creates a new report. Use theXtraReportInstance()
constructor to generate a report instance. Call theCreateDocument()
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; }
-
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(); // ... }
-
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); // ... }
-
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); // ... }
- PDF Viewer
- .NET Reporting Tools for Web, Mobile, and Desktop
- Configure a Report in the Visual Studio Designer
- Configure a Report in the Visual Studio Code Designer
- Create a Report in Code
- DevExpress .NET MAUI Demo Center
- Stocks App
- Data Grid
- Data Form
- Data Editors
- Charts
- Scheduler
- Tab Page
- Tab View
- Drawer Page
- Drawer View
- Collection View
- Popup
(you will be redirected to DevExpress.com to submit your response)