Export Methods and Settings
- 9 minutes to read
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.
Export Methods and Settings
The following table lists available methods for exporting data.
Method | Description |
---|---|
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. | |
Exports the data displayed by the GridControl.DefaultView (the GridControl.MainView or the currently maximized detail View) to the specified stream in CSV format using the specified options. | |
Exports the control’s data in the Office Open XML format (DOCX file) and sends it to the specified stream. | |
Exports the data displayed by the GridControl.DefaultView (the GridControl.MainView or the currently maximized detail View) to the specified stream in HTML format using the specified options. | |
Exports the data displayed by the GridControl.DefaultView (the GridControl.MainView or the currently maximized detail View) to the specified stream in MHT format using the specified options. | |
Exports the data displayed by the GridControl.DefaultView (the GridControl.MainView or the currently maximized detail View) to the specified stream in PDF format. | |
Exports the grid to a stream in RTF format with the specified options. | |
Exports the data displayed by the GridControl.DefaultView (the GridControl.MainView or the currently maximized detail View) to the specified sream in Text format using the specified options. | |
Provide access to print/export options. | |
Provides access to properties that specify the appearances of grid elements when they are printed/exported. | |
Indicates whether the grid control can be printed/exported. | |
Allows you to customize general print/export settings when the View is about to be printed/exported. | |
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. | |
Fires after an individual row has been printed/exported, and allows you to add custom information to the printout/export output. | |
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. | |
Gets or sets whether the grid automatically clears a generated print/export document and then generates this document each time the grid is printed/exported. In server mode, this option is not in effect. | |
Creates a print/export document from the View’s data. | |
Clears a previously generated document for printing/exporting. | |
Gets or sets whether the View is printed/exported with all master rows expanded. |
Note
Custom painting, alpha blending and color gradient features are not supported when the grid’s data is exported.
Note
In Large Data Sources: Server and Instant Feedback Modes, 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.
Export Detail Views
A detail View can be exported as follows:
- along with the Main View, if you expand this detail and enable the GridOptionsPrint.PrintDetails option;
- separately from the Main View, if you zoom to (maximize) this detail. See Master-Detail Relationships to learn more.
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. |
OptionsColumn.Printable | Gets or sets whether a column is included in the print/export output. |
Export Settings Specific to GridViews and Descendants
These options are available via the GridView.OptionsPrint property.
Option | Description |
---|---|
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. | |
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 GridOptionsPrint.UsePrintStyles property is set to true. The default is false. | |
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 GridOptionsPrint.UsePrintStyles property is set to true. The default is false. | |
Gets or sets whether the View is printed/exported with all master rows expanded. The default is false. | |
Gets or sets whether the View is printed/exported with all group rows expanded. The default is true. | |
Gets or sets whether to print/export currently expanded details (in master-detail mode). This property is not in effect when you export the View in Microsoft Excel format in Data-aware export mode. The default is false. | |
Gets or sets whether to display the filter panel in the print/export output. The default is false. | |
Gets or sets whether to display the view footer in the print/export output. Supports WYSIWYG and Data-aware export mode. The default is true. | |
Gets or sets whether to display group footers in the print/export output. The default is true. | |
Gets or sets whether to display column headers in the print/export output. Supports WYSIWYG and Data-aware export mode. The default is true. | |
Gets or sets whether horizontal grid lines are printed/exported. Supports WYSIWYG and Data-aware export mode. The default is true. | |
Gets or sets whether to display the preview sections in the print/export output. The default is false. | |
Gets or sets whether only the focused/selected rows are printed/exported. The default is false. | |
Gets or sets whether vertical grid lines are displayed in the print/export output. Supports WYSIWYG and Data-aware export mode. The default is true. | |
Gets or sets whether preview sections are allowed to be split across pages when printing/exporting. The default is false. | |
Gets or sets whether print appearances are used when the grid control is printed/exported. The default is false. |
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 |
---|---|
Gets or sets whether band headers are printed/exported. The default is true. |
Export Settings Specific to LayoutViews
These options are available via the LayoutView.OptionsPrint object.
Option | Description |
---|---|
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 LayoutViewOptionsPrint.PrintMode property is set to MultiColumn). The default is 0, which means that the number of columns is not limited. | |
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 LayoutViewOptionsPrint.PrintMode property is set to MultiRow). The default is 0, which means that the number of rows is not limited. | |
Gets or sets a value specifying whether card captions are displayed in the print/export output. The default is true. | |
Gets or sets a value specifying whether the filter panel is displayed in the print/export output. The default is false. | |
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. | |
Gets or sets whether only the focused/selected cards are printed/exported. The default is false. | |
Gets or sets whether print styles or the View’s appearance settings are used when printing/exporting the View. The default is false. |
Export Settings Specific to CardViews
These options are available via the CardView.OptionsPrint object.
Option | Description |
---|---|
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. | |
Gets or sets whether card captions are printed/exported. The default is true. | |
Gets or sets whether empty fields are printed/exported. The default is true. | |
Gets or sets whether the filter panel is printed/exported. The default is false. | |
Gets or sets whether only the focused/selected cards are printed/exported. The default is false. | |
Gets or sets whether print styles or View styles are used to print/export the View. The default is false. |
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).
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.
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.