Export to Text
- 2 min to read
This document details the exporting of a document to Text.
A code example illustrating how to export a report to TXT is available at How to export a report to TXT format.
Among these options, the TextExportOptionsBase.TextExportMode property determines whether to use the formatting of data fields in the bound dataset for the cells in the exported Text document. Note that if this property is set to Text, all data fields are exported to the TXT file as strings with the corresponding formatting embedded into those strings.
Note that only the report controls that don't intersect with each other can be correctly exported to Text. In other cases, the resultant TXT file may have a completely broken layout.
To make sure that your report layout will be preserved in a Text format, enable the report's DesignerOptions.ShowExportWarnings property at design time, and check to ensure there are no exclamation marks shown for intersecting controls (colored in red).
Composite report documents created from multiple merged documents cannot be exported to file formats that support a continuous (table-like) layout (such as TXT or CSV).
As a workaround, use subreports to combine multiple XtraReport to a single document. Alternatively, export all your reports to CSV and TXT files separately and then join all the exported data to a single file.
When exporting to a text file, XtraReports uses the protected GetTextView method of the XRControl class, which is overridden in the appropriate report control. This method returns a 2-dimensional array of strings used for the text representation of a control. For instance, the XRLabel is represented as a simple string, the XRRichTextBox as a 1-dimensional array of strings, the XRTable as a 2-dimensional array of strings, and the XRPictureBox can't be represented as a string.