Back to Devexpress

Document Export Overview

xtrareports-2618-feature-guide-to-devexpress-reports-store-and-distribute-reports-export-reports-document-export-overview.md

latest16.6 KB
Original Source

Document Export Overview

  • Feb 18, 2026
  • 5 minutes to read

You can export a report document to multiple formats.

Export a Report

Export Commands

You can export a report from the Report Designer’s Preview and from the Document Viewer on all supported platforms (WinForms, WPF, ASP.NET Web Forms, ASP.NET MVC, and ASP.NET Core).

  1. In the Report Designer, specify export options for the selected format. Specify the XtraReport.DisplayName property, the property value is the default report export file name.

  2. Switch to Preview, expand the Export Document drop-down list and select the format to which you wish to export. Specify export options in the invoked dialog, and click OK.

Visual Export Tool

You can start export in code and invoke the Export Options dialog to enable the user to specify export options. For this, use the VisualExportTool class.

Export in Code

At runtime, the XtraReport class provides methods to export a report document to all supported export formats. Call a report’s export method and pass an ExportOptionsBase descendant class instance as a parameter to specify export options:

Export FormatSynchronous Export MethodAsynchronous Export MethodExport Options
PDFExportToPdf(String, PdfExportOptions)ExportToPdfAsync(String, PdfExportOptions, CancellationToken)PdfExportOptions
DOCXExportToDocx(String, DocxExportOptions)ExportToDocxAsync(String, DocxExportOptions, CancellationToken)DocxExportOptions
RTFExportToRtf(String, RtfExportOptions)ExportToRtfAsync(String, RtfExportOptions, CancellationToken)RtfExportOptions
ImageExportToImage(String, ImageExportOptions)ExportToImageAsync(String, ImageExportOptions, CancellationToken)ImageExportOptions
CSVExportToCsv(String, CsvExportOptions)ExportToCsvAsync(String, CsvExportOptions, CancellationToken)CsvExportOptions
TXTExportToText(String, TextExportOptions)ExportToTextAsync(String, TextExportOptions, CancellationToken)TextExportOptions
XLSExportToXls(String, XlsExportOptions)ExportToXlsAsync(String, XlsExportOptions, CancellationToken)XlsExportOptions
XSLXExportToXlsx(String, XlsxExportOptions)ExportToXlsxAsync(String, XlsxExportOptions, CancellationToken)XlsxExportOptions
HTMLExportToHtml(String, HtmlExportOptions)ExportToHtmlAsync(String, HtmlExportOptions, CancellationToken)HtmlExportOptions
MHTExportToMht(String, MhtExportOptions)ExportToMhtAsync(String, MhtExportOptions, CancellationToken)MhtExportOptions
MailMessageExportToMail(MailMessageExportOptions)ExportToMailAsync(MailMessageExportOptions, CancellationToken)MailMessageExportOptions
csharp
using DevExpress.XtraReports.UI;
// ...

XtraReport report = new XtraReport() {
    Bands = {
        new DetailBand() {
            Name = "DetaiBand",
            Controls = {
                new XRLabel() {
                    Text = "Simple Report"
                }
            }
        }
    }
};
// Set a password to open the PDF export file.
report.ExportOptions.Pdf.PasswordSecurityOptions.OpenPassword = "password";
// 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
Imports DevExpress.XtraReports.UI
' ...

Private report As New XtraReport() With {
    .Bands = {
        New DetailBand() With {
            .Name = "DetaiBand", .Controls = {
                New XRLabel() With {.Text = "Simple Report"}
            }
        }
    }
}
' Set a password to open the PDF export file.
report.ExportOptions.Pdf.PasswordSecurityOptions.OpenPassword = "password"
' 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")

Note

  • Synchronous export methods run until the export document is complete, and it cannot be interrupted or canceled. Other tasks performed in the application are locked during that time.
  • Asynchronous methods run in a separate thread and do not lock other tasks performed concurrently. You can use the CancellationToken parameter to cancel the report export.

Export Modes

Set the ExportOptions.ExportMode property to one of the values below to specify the report document’s export mode:

  • Single File
    The report is exported into one file that contains one page. The report’s page headers, footers, top and bottom margins appear only once, at the beginning and end of the resulting page.
  • Single File Page-by-Page
    The report is exported into one file that contains multiple pages. Each page corresponds to a report document page. The report’s page headers, footers, and top and bottom margins appear on every page, exactly as they appear in the report’s Preview.
  • Different Files
    The report is exported into multiple files. Each file contains one page that corresponds to a report document page. The report’s page headers, footers, and top and bottom margins appear on every page, exactly as they appear in the report’s Preview.

These modes are available in the following export formats:

|

Format

|

Single File

|

Single File Page-by-Page

|

Different Files

| | --- | --- | --- | --- | |

PDF

|

|

|

| |

DOCX

|

|

|

| |

RTF

|

|

|

| |

Image

|

|

|

| |

Text:

|

|

|

| |

Excel:

|

|

|

| |

Web Documents:

|

|

|

|

Use the PrintControl.DisableExportModeValues method to limit the list of export modes available for each export format in your application.

You cannot export reports merged page by page in the Single File export mode. As a workaround:

  • Use subreports to merge multiple reports into a single document.
  • Export all reports to separate files and join these files in a single file.

Export Reports with Overlapped Controls

Overlapped controls are highlighted in reports. Users can position their mouse pointer over such controls to see what needs to be fixed.

Disable a report’s DesignerOptions.ShowExportWarnings property to remove highlights on overlapped controls.

You can export reports with overlapped controls into the following formats:

Note that an attempt to export a report with overlapped controls to another format causes an error.

Hide Report Controls in Documents Exported to Specific Formats

You can specify XRControl.CanPublishOptions to exclude report controls from export if the user selects certain export formats.

The following code snippet excludes page information (the XRPageInfo instance) when exporting a report to XLS, XLSX, and CSV formats:

csharp
using DevExpress.XtraReports.UI;
// ...
XtraReport report = new XtraReport();
  DetailBand detailBand = new DetailBand();
  report.Bands.Add(detailBand);
  XRPageInfo xrPageInfo1 = new XRPageInfo{
  // Add content.
  };
  detailBand.Controls.Add(xrPageInfo1);
  // Hide xrPageInfo1 from XLS, XLSX, and CSV formats.
  xrPageInfo1.CanPublishOptions.Xlsx = false;
  xrPageInfo1.CanPublishOptions.Xls = false;
  xrPageInfo1.CanPublishOptions.Csv = false;
vb
Imports DevExpress.XtraReports.UI
' ...
Private report As New XtraReport()
  Private detailBand As New DetailBand()
  report.Bands.Add(detailBand)
  Dim xrPageInfo1 As XRPageInfo = New XRPageInfo From { }
  detailBand.Controls.Add(xrPageInfo1)
  ' Hide xrPageInfo1 from XLS, XLSX, and CSV formats.
  xrPageInfo1.CanPublishOptions.Xlsx = False
  xrPageInfo1.CanPublishOptions.Xls = False
  xrPageInfo1.CanPublishOptions.Csv = False

You can also specify CanPublishOptions in the Properties grid:

The following image illustrates the resulting XLXS document with and without page information: