Skip to main content
A newer version of this page is available. .

XtraReport Class

A base class for a report.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v18.2.dll

Declaration

public class XtraReport :
    XtraReportBase,
    ISupportInitialize,
    IServiceProvider,
    IServiceContainer,
    IReport,
    IDocumentSource,
    ILink,
    IComponent,
    IDisposable,
    IExtensionsProvider,
    IParameterSupplier,
    IParameterSupplierBase,
    IRootXmlObject

The following members return XtraReport objects:

Show 49 links
Library Related API Members
WPF Controls GridReportManagerService.GenerateReport(XtraReport)
IReportManagerService.GenerateReport(XtraReport)
IReportManagerService.GetReport(ReportInfo)
IReportProvider.GetReport()
IReportProvider.GetReport(String)
IReportSerializer.Load(Stream)
IReportStorage.CreateNew()
IReportStorage.CreateNewSubreport()
IReportStorage.Load(String, IReportSerializer)
IWizardReportProvider.NewReport
IWizardReportProvider.OriginalReport
ReportClonedEventArgs.Cloned
ReportClonedEventArgs.Original
ReportDesignerDocument.Report
ReportManagerService.GenerateReport(XtraReport)
ReportManagerService.GetReport(ReportInfo)
StandaloneReportManagerService.GenerateReport(XtraReport)
Reporting ASPxDocumentViewer.Report
CachedReportSourceWeb.Report
CustomizeParameterEditorsEventArgs.Report
DrillThroughContext.Report
GetValueEventArgs.Report
IReportResolver.Resolve(String, Boolean)
IWebDocumentViewerDrillThroughProcessor.CreateReport(DrillThroughContext)
IWebDocumentViewerReportResolver.Resolve(String)
ReportDesignTool.Report
ReportGenerator.GenerateReport(BaseView, ReportGenerationOptions, Boolean)
ReportGenerator.GenerateReport(BaseView, ReportGenerationOptions)
ReportGenerator.GenerateReport(BaseView)
ReportGenerator.GenerateReport(XtraReport, BaseView, ReportGenerationOptions, Boolean)
ReportGenerator.GenerateReport(XtraReport, BaseView)
ReportViewer.Report
SubreportBase.ReportSource
TypeNameBasedReportResolver.Resolve(String)
XRControl.RootReport
XRCrossBandControl.RootReport
XRDesignPanel.Report
XtraReport.FromFile(String, Boolean)
XtraReport.FromStream(Stream, Boolean)
XtraReport.MasterReport
Dashboard CustomExportEventArgs.Report
CustomExportWebEventArgs.Report
eXpressApp Framework CreateCustomReportDesignRepositoryItemEventArgs.Report
IReportContainer.Report
ReportContainer.Report
ReportsStorage.LoadReport(IReportDataV2)
ReportWebViewerDetailItem.Report
ASP.NET Web Forms Controls DocumentViewerSettings.Report
ReportViewerSettings.Report

Remarks

Follow the steps below to create a report in code:

  • Create a report - the XtraReport class’s instance.
  • Assign a data source to the report’s DataSource property.
  • Create bands and add them to the report’s Bands collection (the DetailBand is mandatory).
  • Create report controls and add them to the report’s bands.
  • Create styles for report elements.

See Cross-Platform Reporting for information on how to preview, print and/or export reports in an application on different platforms.

Use the Report Designer to create reports at design time (see Get Started with DevExpress Reporting to start and Detailed Guide to DevExpress Reporting to get more information). You can also create a reporting application to allow end users to create reports in the Report Designer (see Create End-User Reporting Applications).

Examples

The code sample below creates a new report, sets its name, display name, paper kind and margins, and adds the Detail Band band with the XRLabel control on it.

result-static-report-runtime

using DevExpress.XtraReports.UI;

// ...

public static XtraReport CreateReport() {

    // Create an XtraReport instance
    XtraReport report = new XtraReport() {
        Name = "SimpleStaticReport",
        DisplayName = "Simple Static Report",
        PaperKind = PaperKind.Letter,
        Margins = new Margins(100, 100, 100, 100)
    };

    // Create a Detail band for the report
    DetailBand detailBand = new DetailBand() {
        HeightF = 25
    };

    // Add the created Detail band to the report
    report.Bands.Add(detailBand);

    // Create an XRLabel control for the report
    XRLabel helloWordLabel = new XRLabel() {
        Text = "Hello, World!",
        Font = new Font("Tahoma", 20f, FontStyle.Bold),
        BoundsF = new RectangleF(0, 0, 250, 50),
    };

    // Add the created XRLabel to the Detail band
    detailBand.Controls.Add(helloWordLabel);

    // Return the report with a band and a label on it
    return report;
}

The code sample below creates a simple data-bound report.

result-static-report-runtime

using System.Collections.Generic;
using System.Drawing;
using DevExpress.XtraPrinting;
using DevExpress.XtraReports.UI;

// ...

class Employee {
    public string Name { get; set; }
}

// Create a report and assign bands to it.
public static XtraReport CreateReport() {
    XtraReport report = new XtraReport() {
        DataSource = CreateDataSource(),
        StyleSheet = {
            new XRControlStyle() { Name = "Title", Font = new Font("Tahoma", 20f, FontStyle.Bold) },
            new XRControlStyle() { Name = "Normal", Font = new Font("Tahoma", 10f), Padding = new PaddingInfo(2, 2, 0, 0) },
        }
    };
    var reportHeaderBand = CreateReportHeader("List of employees");
    var detailBand = CreateDetail("[Name]");
    report.Bands.AddRange(new Band[] { reportHeaderBand, detailBand });
    return report;
}

// Create an employees list to serve as the report's data source.
static List<Employee> CreateDataSource() {
    return new List<Employee>() {
        new Employee() { Name = "Nancy Davolio" },
        new Employee() { Name = "Andrew Fuller" },
        new Employee() { Name = "Janet Leverling" },
        new Employee() { Name = "Margaret Peacock" },
        new Employee() { Name = "Steven Buchanan" },
        new Employee() { Name = "Michael Suyama" },
        new Employee() { Name = "Robert King" },
        new Employee() { Name = "Laura Callahan" },
        new Employee() { Name = "Anne Dodsworth" }
    };
}

// Create a Report Header band and add a report title label to it.
static ReportHeaderBand CreateReportHeader(string title) {
    ReportHeaderBand reportHeaderBand = new ReportHeaderBand() {
        HeightF = 50
    };
    XRLabel titleLabel = new XRLabel() {
        Text = title,
        BoundsF = new RectangleF(0, 0, 300, 30),
        StyleName = "Title"
    };
    reportHeaderBand.Controls.Add(titleLabel);
    return reportHeaderBand;
}

// Create a Detail band and add an employee name label to it.
static DetailBand CreateDetail(string expression) {
    DetailBand detailBand = new DetailBand() {
        HeightF = 25
    };
    XRLabel detailLabel = new XRLabel() {
        ExpressionBindings = { new ExpressionBinding("Text", expression) },
        BoundsF = new RectangleF(0, 0, 300, 20),
        StyleName = "Normal"
    };
    detailBand.Controls.Add(detailLabel);
    return detailBand;
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the XtraReport class.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

Implements

Show 18 items
DevExpress.Utils.Serializing.Helpers.IXtraSupportDeserializeCollectionItem
DevExpress.Utils.Serializing.IXtraSerializable
DevExpress.Data.IDataContainerBase
DevExpress.Data.IDataContainerBase2
DevExpress.Data.Browsing.IDataContextContainer
DevExpress.Data.IFilterStringContainer
DevExpress.XtraPrinting.IBrickOwnerRepository
DevExpress.Data.IParameterSupplierBase
See Also