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
  [Collapse]Data Grid
   [Expand]Getting Started
   [Expand]Binding to Data
   [Expand]Grid View
   [Expand]View Technology
   [Expand]Grouping
   [Expand]Sorting
   [Expand]Summaries
   [Expand]Data Editing
   [Expand]Filtering and Locating Rows
   [Expand]Focus and Selection Handling
   [Expand]Processing Rows
   [Expand]Formatting Cell Values
   [Expand]Master-Detail Relationships
   [Expand]Asynchronous Image Load
   [Collapse]Export and Printing
     Printing Overview
     Member Table: Printing
     Export Overview
     Export Methods and Settings
     Export to XLS and XLSX Formats
     Advanced Grid Printing and Exporting
   [Expand]Appearance and Conditional Formatting
   [Expand]Batch Modifications
   [Expand]Hit Information
   [Expand]Hints
   [Expand]Popup Menus
   [Expand]Saving and Restoring Layouts
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]Examples
   [Expand]End-User Capabilities
    Included Components
  [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
  [Expand]Printing-Exporting
  [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]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]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Export Methods and Settings

The Grid Control provides a set of methods that allow you to export data in various formats. These methods export data using routines implemented in the XtraPrinting Library.

For information on exporting data to MS Excel format, see Export to XLS and XLSX Formats.

Expanded Export Methods and Settings

The following table lists available methods for exporting data.

Method Description
BaseView.Export Exports the data displayed by the GridControl.DefaultView (the GridControl.MainView or the currently maximized detail View) in the specified format to a stream, using the specified options.
GridControl.ExportToCsv Exports the data displayed by the DefaultView (the MainView or the currently maximized detail View) to the specified stream in CSV format using the specified options.
GridControl.ExportToHtml Exports the data displayed by the DefaultView (the MainView or the currently maximized detail View) to the specified file in HTML format.
GridControl.ExportToMht Exports the data displayed by the DefaultView (the MainView or the currently maximized detail View) to a stream in MHT format using the specified character encoding, with the specified title. The output file can be compressed (secondary characters e.g. spaces are removed) if required.
GridControl.ExportToPdf Exports the data displayed by the DefaultView (the MainView or the currently maximized detail View) to the specified stream in PDF format.
GridControl.ExportToRtf Exports the data displayed by the DefaultView (the MainView or the currently maximized detail View) to a file in RTF format.
GridControl.ExportToText Exports the data displayed by the DefaultView (the MainView or the currently maximized detail View) to the specified file in TXT format.
GridView.OptionsPrint
BandedGridView.OptionsPrint
LayoutView.OptionsPrint
CardView.OptionsPrint
Provide access to print/export options.
GridView.AppearancePrint
BandedGridView.AppearancePrint
LayoutView.AppearancePrint
CardView.AppearancePrint
Provides access to properties that specify the appearances of grid elements when they are printed/exported.
GridControl.IsPrintingAvailable Indicates whether the grid control can be printed/exported.
BaseView.PrintInitialize Allows you to customize general print/export settings when the View is about to be printed/exported.
GridView.BeforePrintRow Fires before printing/exporting each individual row, and allows you to add custom information to the printout/export output, and prevent a row from being printed/exported.
GridView.AfterPrintRow Fires after an individual row has been printed/exported, and allows you to add custom information to the printout/export output.
GridView.GetGroupRowPrintValue Returns the export value corresponding to the specified group row. The value will be exported when exporting the grid View's data as values, not as display text in MS Excel format.
ViewPrintOptionsBase.AutoResetPrintDocument Gets or sets whether a print/export document is automatically cleared and then generated each time it is sent to the print/export output. In server mode, this option is not in effect.
BaseView.CreateDocument Creates a print/export document based on the View's current data.
BaseView.ClearDocument Clears a print/export document.
Note

Custom painting, alpha blending and color gradient features are not supported when the grid's data is exported.

Note

In Server Mode, a print/export document is not regenerated each time it is sent to the print/export output. This means that if a print/export document has been generated and it's not empty, subsequent changes to the grid's layout (changing filter, sort and group settings, modifying cell values, etc.) are not applied when you send the grid's data to the print/export output the next time. To apply the changes made, call the BaseView.CreateDocument method before sending the grid's data to the print/export output.

Expanded Export Detail Views

A detail View can be exported as follows:

Expanded Export Settings of a Column/Field

Option Description
RepositoryItem.ExportMode Specifies whether the editor's value or display text is exported when data is exported to XLS and CSV formats. This property is not in effect in Data-Aware export mode.
OptionsColumn.Printable Gets or sets whether a column is included in the print/export output.

Expanded Export Settings Specific to GridViews and Descendants

These options are available via the GridView.OptionsPrint property.

Option Description
GridOptionsPrint.AutoWidth Gets or sets whether widths of columns in the print/export output are automatically changed so that the View fits the page width. The default is true. This property is in effect when exporting to HTML, PDF, RTF and XLS.
GridOptionsPrint.EnableAppearanceEvenRow Gets or sets whether even rows in the print/export output are painted using the appearance settings provided by the GridViewPrintAppearances.EvenRow property. This option is in effect when the UsePrintStyles property is set to true. The default is false.
GridOptionsPrint.EnableAppearanceOddRow Gets or sets whether odd rows in the print/export output are painted using the appearance settings provided by the GridViewPrintAppearances.OddRow property. This option is in effect when the UsePrintStyles property is set to true. The default is false.
GridOptionsPrint.ExpandAllDetails Gets or sets whether the View is printed/exported with all master rows expanded. The default is false.
GridOptionsPrint.ExpandAllGroups Gets or sets whether the View is printed/exported with all group rows expanded. The default is true.
GridOptionsPrint.PrintDetails Gets or sets to print/export details of master rows. The default is false.
GridOptionsPrint.PrintFilterInfo Gets or sets whether to display the filter panel in the print/export output. The default is false.
GridOptionsPrint.PrintFooter Gets or sets whether to display the view footer in the print/export output. When exporting to Xls(x) format, this property is supported in both WYSIWYG and Data-aware export mode. The default is true.
GridOptionsPrint.PrintGroupFooter Gets or sets whether to display group footers in the print/export output. The default is true.
GridOptionsPrint.PrintHeader Gets or sets whether to display column headers in the print/export output. When exporting to Xls(x) format, this property is supported in both WYSIWYG and Data-aware export mode. The default is true.
GridOptionsPrint.PrintHorzLines Gets or sets whether horizontal grid lines are printed/exported. When exporting to Xls(x) format, this property is supported in both WYSIWYG and Data-aware export mode. The default is true.
GridOptionsPrint.PrintPreview Gets or sets whether to display the preview sections in the print/export output. The default is false.
GridOptionsPrint.PrintSelectedRowsOnly Gets or sets whether only the focused/selected rows are printed/exported. The default is false.
GridOptionsPrint.PrintVertLines Gets or sets whether vertical grid lines are displayed in the print/export output. When exporting to Xls(x) format, this property is supported in both WYSIWYG and Data-aware export mode. The default is true.
GridOptionsPrint.SplitCellPreviewAcrossPages Gets or sets whether preview sections are allowed to be split across pages when printing/exporting. The default is false.
GridOptionsPrint.UsePrintStyles Gets or sets whether print appearances are used when the grid control is printed/exported. The default is false.

Expanded Export Settings Specific to BandedGridViews and Descendants

These options (available via the BandedGridView.OptionsPrint object) are the same as those provided by the GridView.OptionsPrint object, plus the following:

Option Description
BandedGridOptionsPrint.PrintBandHeader Gets or sets whether band headers are printed/exported. The default is true.

Expanded Export Settings Specific to LayoutViews

These options are available via the LayoutView.OptionsPrint object.

Option Description
LayoutViewOptionsPrint.MaxCardColumns Gets or sets the maximum number of columns in the print/export output. This option is in effect when cards are arranged in multiple columns (the PrintMode property is set to MultiColumn). The default is 0, which means that the number of columns is not limited.
LayoutViewOptionsPrint.MaxCardRows Gets or sets the maximum number of rows in the print/export output. This option is in effect when cards are arranged in multiple rows (the PrintMode property is set to MultiRow). The default is 0, which means that the number of rows is not limited.
LayoutViewOptionsPrint.PrintCardCaption Gets or sets a value specifying whether card captions are displayed in the print/export output. The default is true.
LayoutViewOptionsPrint.PrintFilterInfo Gets or sets a value specifying whether the filter panel is displayed in the print/export output. The default is false.
LayoutViewOptionsPrint.PrintMode Gets or sets the card layout when the View is printed/exported. The default is LayoutViewPrintMode.Default, which means that cards are arranged in multiple columns.
LayoutViewOptionsPrint.PrintSelectedCardsOnly Gets or sets whether only the focused/selected cards are printed/exported. The default is false.
LayoutViewOptionsPrint.UsePrintStyles Gets or sets whether print styles or the View's appearance settings are used when printing/exporting the View. The default is false.

Expanded Export Settings Specific to CardViews

These options are available via the CardView.OptionsPrint object.

Option Description
CardOptionsPrint.AutoHorzWidth Gets or sets whether cards in the print/export output are automatically resized horizontally to fit the report page's width. The default is false.
CardOptionsPrint.PrintCardCaption Gets or sets whether card captions are printed/exported. The default is true.
CardOptionsPrint.PrintEmptyFields Gets or sets whether empty fields are printed/exported. The default is true.
CardOptionsPrint.PrintFilterInfo Gets or sets whether the filter panel is printed/exported. The default is false.
CardOptionsPrint.PrintSelectedCardsOnly Gets or sets whether only the focused/selected cards are printed/exported. The default is false.
CardOptionsPrint.UsePrintStyles Gets or sets whether print styles or View styles are used to print/export the View. The default is false.

Expanded Common Appearance Export Settings

By default, any View's appearance settings in the export output are specified by the View's Appearance property. To use different appearance settings when the View is exported, set the View's OptionsPrint.UsePrintStyles property to true. In this instance, the View will be exported using a predefined grayscale paint scheme by default. To specify different print appearance settings use the View's AppearancePrint property (GridView.AppearancePrint, BandedGridView.AppearancePrint, LayoutView.AppearancePrint and CardView.AppearancePrint).

Expanded Advanced Export Settings

Each of the ExportToHtml, ExportToMht and ExportToText methods mentioned at the top of the document provides an overload allowing you to customize advanced export options (encoding type, separators, range of pages, title, etc.). These overloads take additional parameters, represented by the HtmlExportOptions, MhtExportOptions and TextExportOptions class objects. See these links to learn more.

Expanded Exporting to Other Formats and Customizing Export Output

The Grid Control doesn't provide direct methods for exporting data in some additional formats (for instance, BMP and PNG), although the XtraPrinting Library may support them. You can export grid data in any format that is supported by the XtraPrinting Library using the methods provided by the library. See Export a Control in Various Formats (PDF, HTML, BMP, etc.) Using the XtraPrinting Library for more details.

You may also find it useful to export grid data using the methods provided by the XtraPrinting Library if you need to customize the report (add a report header, footer, etc.). See How to: Set Paper Format and Add Custom Information to the Report when Printing/Exporting a Control for more information.

Expanded See Also

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