XtraReport.ExportToText(Stream, TextExportOptions) Method

Exports a report to the specified stream in Text format using the specified Text-specific options.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v18.2.dll


public void ExportToText(
    Stream stream,
    TextExportOptions options
Public Sub ExportToText(
    stream As Stream,
    options As TextExportOptions


Type Name Description
Stream stream

A Stream object to which the created Text file should be sent.

TextExportOptions options

A TextExportOptions object which specifies the Text export options to be applied when a report is exported.

Once the document export has started, it will run until the resulting document is complete and cannot be interrupted or canceled in the process.

Use this method to export a report in Text format using the specified Text export options (like TextExportOptionsBase.Encoding, TextExportOptionsBase.Separator and others.) Note that in this instance the current report export options, which are represented by the TextExportOptions object returned by the ExportOptions.Text property of a report's XtraReport.ExportOptions, are ignored.

If you want to use the current export options of a report, you should call the overloaded XtraReport.ExportToText method without the options parameter.


For more information on using the ExportToText method, and limitations on export to Text, please refer to the Export to Text document.


The following example demonstrates how to export a report to Text format. To do this, the XtraReport.ExportToText method should be used. It also demonstrates what specific TextExportOptions may be used when a report is exported to Text.

For this example to work, you first need to add a new report (named XtraReport1) to your project, drop some report controls onto it, and then execute the code below (for instance, in the Button.Click event handler of any button on a form). Note also, that if you want the resulting file to be automatically opened in the default program which is used to open *.txt files in your system, you can call the StartProcess method, which is also shown in this example.

using System.Text;
using System.Diagnostics;
using System.Globalization;
using DevExpress.XtraPrinting;
using DevExpress.XtraReports.UI;
// ...

private void ExportToText()
    // A path to export a report.
    string reportPath = "c:\\Test.txt";

    // Create a report instance.
    XtraReport1 report = new XtraReport1();

    // Get its Text export options.
    TextExportOptions txtOptions = report.ExportOptions.Text;

    // Set Text-specific export options.
    txtOptions.Encoding = Encoding.Unicode;
    txtOptions.Separator = CultureInfo.CurrentCulture.TextInfo.ListSeparator.ToString();

    // Export the report to Text.

    // Show the result.

// Use this method if you want to automaically open
// the created Text file in the default program.
public void StartProcess(string path)
    Process process = new Process();
        process.StartInfo.FileName = path;
    catch { }

See Also