Back to Devexpress

Print and Export Reports without a Preview

xtrareports-14950-feature-guide-to-devexpress-reports-store-and-distribute-reports-print-and-export-reports-without-a-preview.md

latest7.7 KB
Original Source

Print and Export Reports without a Preview

  • Feb 18, 2026
  • 4 minutes to read

Users can print or export a report when it is displayed in the Document Viewer. As an alternative, you can print and export reports without having to display them first, as described in this topic.

Create a Report

You can add a report to your application in Visual Studio. See the Create a Report in Visual Studio topic for information on how to do this.

Reports can also be created in application code. See the XtraReport class description for more information.

Use the PrintToolBase.Print method to print a report, as shown in the following code sample:

csharp
using DevExpress.XtraPrinting;
using DevExpress.XtraReports.UI;
using System.Drawing.Printing;
// ...

// Create a simple report in code.
XtraReport report = new XtraReport() {
    Bands = {
        new DetailBand() {
            Name = "DetailBand",
            Controls = {
                new XRLabel() {
                    Text = "Simple Report"
                }
            }
        }
    }
};
// Print the report.
report.CreateDocument();
PrintToolBase tool = new PrintToolBase(report.PrintingSystem);
tool.Print();
vb
Imports DevExpress.XtraPrinting
Imports DevExpress.XtraReports.UI
Imports System.Drawing.Printing
' ...

' Create a simple report in code.
Private report As New XtraReport() With {
    .Bands = {
        New DetailBand() With {
            .Name = "DetailBand", .Controls = {
                New XRLabel() With {.Text = "Simple Report"}
            }
        }
    }
}
' Print the report.
report.CreateDocument()
Dim tool As New PrintToolBase(report.PrintingSystem)
tool.Print()

Note

In a server-side application, (for instance, in a web application), the code above sends a report to the default server-side printer.

The Print Reports section describes how to print reports on different platforms.

Export a Report

The XtraReport class exposes methods to export a report to different file formats. Call these methods to export a report from an application that does not have a GUI.

csharp
using DevExpress.XtraReports.UI;
// ...

// Create a simple report in code.
XtraReport report = new XtraReport() {
    Bands = {
        new DetailBand() {
            Name = "DetailBand",
            Controls = {
                new XRLabel() {
                    Text = "Simple Report"
                }
            }
        }
    }
};
// Export the report to PDF.
//Save the export file to the user's Downloads folder.
report.ExportToPdf(
    Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) +
    @"\Downloads\" + report.Name + ".pdf"
);
vb
Private report As New XtraReport() With {
    .Bands = {
        New DetailBand() With {
            .Name = "DetailBand", .Controls = {
                New XRLabel() With {.Text = "Simple Report"}
            }
        }
    }
}
' Export the report to PDF. Save the export file to the user's Downloads folder.
report.ExportToPdf(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) & "\Downloads\" & report.Name & ".pdf")

Review the following topic for information on how to export a report to different file formats: Document Export Overview.

Libraries Required to Print and Export Reports

Add the following libraries to your application to print and export reports. Alternatively, you can add the DevExpress.Reporting.Core NuGet package that includes these core libraries.

AssemblyDescription
DevExpress.Data.v25.2.dllContains base classes for DevExpress controls.
DevExpress.Drawing.v25.2.dllImplements the basic graphics functionality.
DevExpress.Printing.v25.2.Core.dllImplements basic DevExpress printing features.
DevExpress.XtraReports.v25.2.dllContains the XtraReport class.
Optional AssemblyDescription
DevExpress.Charts.v25.2.Core.dllRequired if a report contains XRChart controls.
DevExpress.CodeParser.v25.2.dllRequired to process report scripts.
DevExpress.Data.Desktop.v20.1.dllContains base classes for DevExpress controls in .NET Framework and .NET. Includes classes that bind data, print, and export content. This library is required if you use the WinControlContainer class to print WinForms controls.
DevExpress.DataAccess.v25.2.dllRequired when a report is bound to an SQL, Entity Framework, XPO, Excel, JSON, Object, or Federation data source.
DevExpress.Office.v25.2.Core.dllRequired to export reports to DOCX, or when a report contains XRRichText controls.
DevExpress.Pdf.v25.2.Core.dllRequired to export reports to PDF.
DevExpress.Pdf.v20.1.Drawing.dllImplements PDF-related features. Required to preview reports that are merged with PDF content.
DevExpress.PivotGrid.v25.2.Core.dllRequired if a report contains XRPivotGrid or XRCrossTab controls.
DevExpress.RichEdit.v25.2.Core.dllRequired to export reports to DOCX, or when a report contains at least one XRRichText control.
DevExpress.RichEdit.v25.2.Export.dllRequired to export reports to DOCX.
DevExpress.Sparkline.v25.2.Core.dllRequired if a report contains XRSparkline controls.
DevExpress.Xpo.v25.2.dllRequired if a report is bound to an SQL, XPO, or Entity Framework data source.
DevExpress.XtraCharts.v25.2.dllRequired if a report contains XRChart controls.

See Also

Print Reports

Export Reports