Skip to main content

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

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 GridControl.DefaultView (the GridControl.MainView or the currently maximized detail View) to the specified stream in CSV format using the specified options.

GridControl.ExportToDocx

Exports the control’s data in the Office Open XML format (DOCX file) and sends it to the specified stream.

GridControl.ExportToHtml

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.

GridControl.ExportToMht

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.

GridControl.ExportToPdf

Exports the data displayed by the GridControl.DefaultView (the GridControl.MainView or the currently maximized detail View) to the specified stream in PDF format.

GridControl.ExportToRtf

Exports the grid to a stream in RTF format with the specified options.

GridControl.ExportToText

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.

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 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.

BaseView.CreateDocument

Creates a print/export document from the View’s data.

BaseView.ClearDocument

Clears a previously generated document for printing/exporting.

GridOptionsPrint.ExpandAllDetails

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:

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

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 GridOptionsPrint.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 GridOptionsPrint.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 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.

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. Supports 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. Supports WYSIWYG and Data-aware export mode. The default is true.

GridOptionsPrint.PrintHorzLines

Gets or sets whether horizontal grid lines are printed/exported. Supports 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. Supports 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.

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.

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 LayoutViewOptionsPrint.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 LayoutViewOptionsPrint.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.

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.

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.

See Also