Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Collapse]Printing-Exporting
   [Expand]Product Information
   [Expand]Getting Started
   [Expand]Fundamental Concepts
   [Collapse]Concepts
    [Expand]Basic Terms
    [Expand]Print Preview
    [Collapse]Exporting
      Export to PDF
      Export to HTML
      Export to MHT
      Export to Text
      Export to CSV
      Export to XLS
      Export to XLSX
      Export to RTF
      Export to DOCX
      Export to Image
      Export to MailMessage
    [Expand]Miscellaneous
   [Expand]Examples
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Export to CSV

This document details exporting a document to CSV (comma-separated values) format.

Tip

A code example illustrating how to export a report to CSV is available at How to export a report to CSV format.

The options which can be specified for a document exported to a CSV file are stored in the CsvExportOptions class, and can be accessed via a report's ExportOptions.Csv property.

  • Among these options, the TextExportOptionsBase.TextExportMode property determines whether the data fields format is used in the bound dataset for the cells in the exported CSV document.

    If this property is set to Text, all data fields are exported to the CSV file as strings, with the corresponding formatting embedded into those strings.

  • To specify whether or not the resulting CSV file should include empty columns and/or rows, use the CsvExportOptions.SkipEmptyColumns and CsvExportOptions.SkipEmptyRows properties.

Note

Only the report controls that do not intersect with each other can be correctly exported to CSV. In other cases, the resulting CSV file may have a completely broken layout.

To make sure that your report layout will be preserved in a CSV 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).


When exporting to a CSV file, XtraReports uses the protected GetTextView method of the XRControl class, which is overridden in the appropriate report control. This method returns a two-dimensional string array used for the text representation of a control. For instance, the XRLabel is represented as a simple string, the XRRichTextBox as a one-dimensional array of strings, the XRTable as a two-dimensional array of strings, and the XRPictureBox cannot be represented as a string.

Note

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.

How would you rate this topic?​​​​​​​