XtraReport Class
A DevExpress report.
Namespace: DevExpress.XtraReports.UI
Assembly: DevExpress.XtraReports.v24.1.dll
NuGet Package: DevExpress.Reporting.Core
Declaration
public class XtraReport :
XtraReportBase,
ISupportInitialize,
IServiceProvider,
IServiceContainer,
IReport,
IDocumentSource,
ILink,
IComponent,
IDisposable,
IExtensionsProvider,
IParameterSupplier,
IParameterSupplierBase,
IRootXmlObject,
IReportEvents
Remarks
For general information on DevExpress Reporting, refer to the following topic: Get Started with DevExpress Reporting.
Create a Report
You can use the Visual Studio Report Designer to create reports for most common scenarios. You can also create and customize reports in code. See the following documents for more information on both methods:
- Create a Report in Visual Studio – explains how to get started with the Visual Studio Report Designer.
- Create a Report in Code – a detailed guide on how to create reports in code.
- Detailed Guide to DevExpress Reporting – the documents in this section contain detailed information on how to work with reports (bind to data, use report controls, export, and more) in the Report Designer. Most of the documents also explain how to do it in code.
Display a Prepared Report in Your Application
DevExpress Reporting ships with the Document Viewer and the End-User Report Designer components for the following Microsoft platforms:
- WinForms
- WPF
- ASP.NET Web Forms
- ASP.NET MVC
- ASP.NET Core
- Blazor Server – includes a native viewer and a JavaScript-based viewer and designer.
- WinUI – includes a viewer only.
Each component includes an API that accepts an XtraReport class instance. You can create an instance of your report in code and use this API to pass your report to the Document Viewer or open it in the End-User Report Designer.
The following example shows how to display a report in the WinForms Document Viewer control:
using DevExpress.XtraReports.UI;
//...
ReportPrintTool printTool = new ReportPrintTool(new XtraReport1());
printTool.ShowRibbonPreview();
The example below demonstrates how to open a report in the ASP.NET Core Document Viewer:
@{
var viewerRender = Html.DevExpress().WebDocumentViewer("DocumentViewer")
.Height("1000px")
.Bind(new XtraReport1());
@viewerRender.RenderHtml()
}
You can find a list of all available platforms and more information on each of them in the following documentation section: Integrate a Report into the User Interface.
Print or Export a Report
The Report Designer serializes your report while you create it in Visual Studio. This serialization mechanism allows you to create an instance of your report in code. You can then export or print the created report without showing it in the Document Viewer. The latter also applies to reports created in code from scratch.
The following example creates a report instance and exports it to PDF:
using System;
//..
var report = new XtraReport1();
report.ExportToPdf(Environment.GetFolderPath(
Environment.SpecialFolder.UserProfile) + @"\Downloads\Report1.pdf"
);
Refer to the following document for more information: Print and Export Reports without a Preview.