Back to Devexpress

Export to RTF

xtrareports-2580-feature-guide-to-devexpress-reports-store-and-distribute-reports-export-reports-export-to-rtf.md

latest15.8 KB
Original Source

Export to RTF

  • Feb 18, 2026
  • 9 minutes to read

This document describes how to export a report document to RTF format.

You can export a report from the Report Designer’s Preview and the Document Viewer on all supported platforms (WinForms, WPF, ASP.NET Web Forms, ASP.NET MVC, and ASP.NET Core). To do this, expand the Export Document drop-down list and select RTF File. Specify export options in the invoked dialog, and click OK.

To export a report document to RTF format in code, use one of the following approaches:

Export a Report

Call an XtraReport.ExportToRtf overloaded method to export a report. To export a report asynchronously in a separate task, call an XtraReport.ExportToRtfAsync overloaded method instead. To specify export options, create a RtfExportOptions class instance and pass this instance to the invoked method, or use XtraReport ‘s ExportOptions.Rtf property.

csharp
using System;
using DevExpress.XtraPrinting;
using DevExpress.XtraReports.UI;
// ...
XtraReport report = new XtraReport() {
    Name = "HelloWorld",
    Bands = {
        new DetailBand(){
            Controls={
                new XRLabel(){
                    Text="Hello World!"
                }
            }
        }
    }
};
// rtfExportFile specifies the exported file's name and path. The user's Downloads folder is used as the default path.
string rtfExportFile = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\Downloads\" + report.Name + ".rtf";
// Specify export options to export the report.
// Uncomment the lines below to specify export options in an RtfExportOptions class instance.
// RtfExportOptions RtfExportOptions = new RtfExportOptions();
// RtfExportOptions.ExportMode = RtfExportMode.SingleFile;
// report.ExportToRtf(rtfExportFile, RtfExportOptions);

// Comment the lines below if you specified export options in an RtfExportOptions class instance above.
report.ExportOptions.Rtf.ExportMode = RtfExportMode.SingleFile;
report.ExportToRtf(rtfExportFile);
vb
Imports System
Imports DevExpress.XtraPrinting
Imports DevExpress.XtraReports.UI
' ...
Private report As New XtraReport() With {
    .Name = "HelloWorld", .Bands = {
        New DetailBand() With {
            .Controls={
                New XRLabel() With {.Text="Hello World!"}
            }
        }
    }
}
' rtfExportFile specifies the exported file's name and path. The user's Downloads folder is used as the default path.
Private rtfExportFile As String = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) & "\Downloads\" & report.Name & ".rtf"
' Specify export options and export the report.
' Uncomment the lines below to specify export options in an RtfExportOptions class instance.
' RtfExportOptions RtfExportOptions = new RtfExportOptions();
' RtfExportOptions.ExportMode = RtfExportMode.SingleFile;
' report.ExportToRtf(rtfExportFile, RtfExportOptions);

' Comment the lines below if you specified export options in an RtfExportOptions class instance above.
report.ExportOptions.Rtf.ExportMode = RtfExportMode.SingleFile
report.ExportToRtf(rtfExportFile)

Export a Document

Call a PrintingSystem.ExportToRtf overloaded method to export a document. To specify export options, create a RtfExportOptions class instance and pass this instance to the invoked method, or use PrintingSystem ‘s ExportOptions.Rtf property.

csharp
using System;
using DevExpress.XtraPrinting;
using DevExpress.XtraReports.UI;
// ...
XtraReport report = new XtraReport() {
    Name = "HelloWorld",
    Bands = {
        new DetailBand(){
            Controls={
                new XRLabel(){
                    Text="Hello World!"
                }
            }
        }
    }
};
// Create a document from the report.
report.CreateDocument();
// rtfExportFile specifies the exported file's name and path. The user's Downloads folder is used as the default path.
string rtfExportFile = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\Downloads\" + report.Name + ".rtf";
// Specify export options and export the document.
// Uncomment the lines below to specify export options in an RtfExportOptions class instance.
// RtfExportOptions RtfExportOptions = new RtfExportOptions();
// RtfExportOptions.ExportMode = RtfExportMode.SingleFile;
// report.PrintingSystem.ExportToRtf(rtfExportFile, RtfExportOptions);

// Comment the lines below if you specified export options in an RtfExportOptions class instance above.
report.PrintingSystem.ExportOptions.Rtf.ExportMode = RtfExportMode.SingleFile;
report.PrintingSystem.ExportToRtf(rtfExportFile);
vb
Imports System
Imports DevExpress.XtraPrinting
Imports DevExpress.XtraReports.UI
' ...
Private report As New XtraReport() With {
    .Name = "HelloWorld", .Bands = {
        New DetailBand() With {
            .Controls={
                New XRLabel() With {.Text="Hello World!"}
            }
        }
    }
}
' Create a document from the report.
report.CreateDocument()
' rtfExportFile specifies the exported file's name and path. The user's Downloads folder is used as the default path.
Dim rtfExportFile As String = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) & "\Downloads\" & report.Name & ".rtf"
' Specify export options and export the document.
' Uncomment the lines below to specify export options in an RtfExportOptions class instance.
' RtfExportOptions RtfExportOptions = new RtfExportOptions();
' RtfExportOptions.ExportMode = RtfExportMode.SingleFile;
' report.PrintingSystem.ExportToRtf(rtfExportFile, RtfExportOptions);

' Comment the lines below if you specified export options in an RtfExportOptions class instance above.
report.PrintingSystem.ExportOptions.Rtf.ExportMode = RtfExportMode.SingleFile
report.PrintingSystem.ExportToRtf(rtfExportFile)

Export a Control

Call a PrintingLink.ExportToRtf overloaded method to export a control. To specify export options, create a RtfExportOptions class instance and pass this instance to the invoked method.

csharp
using System;
using DevExpress.XtraPrinting;
using DevExpress.XtraReports.UI;
// ...
DevExpress.XtraCharts.ChartControl chart = new DevExpress.XtraCharts.ChartControl() {
    Name = "IncomeByQuarter",
    Series = {
        new DevExpress.XtraCharts.Series("2019", DevExpress.XtraCharts.ViewType.Bar)
    }
};
// Create a printing link.
PrintingSystem printingSystem = new PrintingSystem();
PrintableComponentLink link = new PrintableComponentLink();
printingSystem.Links.Add(link);
link.Component = chart;
// rtfExportFile specifies the exported file's name and path. The user's Downloads folder is used as the default path.
string rtfExportFile = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\Downloads\" + chart.Name + ".rtf";
// Specify export options and export the control.
RtfExportOptions RtfExportOptions = new RtfExportOptions();
RtfExportOptions.ExportMode = RtfExportMode.SingleFile;
link.ExportToRtf(rtfExportFile, RtfExportOptions);
vb
Imports System
Imports DevExpress.XtraPrinting
Imports DevExpress.XtraReports.UI
' ...
Private chart As New DevExpress.XtraCharts.ChartControl() With {
    .Name = "IncomeByQuarter", .Series = { New DevExpress.XtraCharts.Series("2019", DevExpress.XtraCharts.ViewType.Bar) }
}
' Create a printing link.
Private printingSystem As New PrintingSystem()
Private link As New PrintableComponentLink()
printingSystem.Links.Add(link)
link.Component = chart
' rtfExportFile specifies the exported file's name and path. The user's Downloads folder is used as the default path.
Dim rtfExportFile As String = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) & "\Downloads\" & chart.Name & ".rtf"
' Specify export options and export the control.
Dim RtfExportOptions As New RtfExportOptions()
RtfExportOptions.ExportMode = RtfExportMode.SingleFile
link.ExportToRtf(rtfExportFile, RtfExportOptions)

Specify RTF Export Options

The RtfExportOptions class exposes options for report export to to RTF. Use the report’s ExportOptions.Rtf property to access these options.

The RtfExportOptions.ExportMode property specifies how a document is exported to RTF:

Note

Not all programs that can be used to view and edit RTF files can correctly process the RTF export files. For instance, Microsoft® Word® displays these files correctly but WordPad ® does not. This is because WordPad does not fully support the RTF standard.

The following table lists RTF-specific options and export modes where these options are supported:

|

Option

|

Single File

(Continuous)

|

Single File

Page-by-Page

|

Description

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

FormattedTextExportOptions.ExportWatermarks

|

|

|

Specifies whether to include the text and image watermarks in the RTF file.

| |

FormattedTextExportOptions.PageRange

|

|

|

Specifies the page range to export to RTF.

| |

FormattedTextExportOptions.KeepRowHeight

|

|

|

Specifies whether the table row heights should be fixed in the export document.

| |

FormattedTextExportOptions.EmptyFirstPageHeaderFooter

|

|

|

Defines whether to display the header and footer contents on the exported document’s first page.

| |

FormattedTextExportOptions.ExportPageBreaks

|

|

|

Specifies whether to include page breaks in the exported file.

|

The following specifics apply to documents exported in the RtfExportMode.SingleFile mode:

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

  • To ensure that report controls are exported correctly, they should not intersect. Otherwise, the file layout can be corrupted.

  • When a document is exported to RTF in a table-like layout, Microsoft® Word® can set table row heights to fit content. As a result, the exported document can differ from the initial document in Print Preview. To avoid this effect, enable the FormattedTextExportOptions.KeepRowHeight property.

  • To locate controls’ content in the export file’s native header and footer sections, place these controls in the TopMarginBand or BottomMarginBand rather than in the page footer and header.

  • If a report uses a CachedReportSource, changes made in Preview are not included in the exported file.

  • To export XRPdfContent and XRSubreport controls with multiple page settings, use Export to Docx - Single Page export mode.

Vector images (for instance, pictures, charts, or bar codes) are rasterized in the exported file. Use the PageByPageExportOptionsBase.RasterizationResolution property to specify the image resolution.

Post-Process RTF Files

You can post-process the resulting RTF files with the help of a dedicated DevExpress library: Word Processing Document API. This product helps you edit, merge, split, and password-protect RTF files.

You may also use Word Processing Document API to generate rich text documents from scratch. If that code-only approach suits your requirements, you don’t need to construct a report in the designer at all.

Word Processing Document API works in desktop and web applications that target a variety of platforms (Windows Forms, WPF, ASP.NET Web Forms, ASP.NET MVC, ASP.NET Core, Blazor, MAUI) and operating systems (Windows, Linux, macOS).

You need a license for the DevExpress Office File API Subscription or DevExpress Universal Subscription to use the Word Processing Document API in production code.

Warning

The Office File API (Basic Edition), which included the Word Processing Document API and Excel Export API libraries, was discontinued on October 17, 2024. If you purchased a DevExpress Universal , DXperience , WinForms , WPF , Office File API , Reporting and ASP.NET subscription before October 17, 2024, our Office File API (Basic Edition) will remain available to you. If you are new to DevExpress and are interested in our Office File API, please refer to the following webpage for pricing/licensing information: DevExpress Office File API

If you have not yet done so, download our fully-functional 30-day trial version to try out DevExpress controls and libraries in your projects:

Download: Free 30-Day Trial