Export¶
Starting with version 1.2, the DataGrid control can export data to XLSX (Microsoft Excel) and PDF formats.
Note
The export functionality is implemented in the Eremex.DocumentProcessing library. Ensure that this library in included in your project to use the export feature.
Export to XLSX Format¶
The Excel export engine is data-aware, meaning it preserves the grid's data shaping options in the output XLSX document, including:
- Row grouping
- Value formatting
- Data sorting
After data is exported, you can process and analyze it in Microsoft Excel or another worksheet processing application.

Note
Cell formatting implemented using cell templates (GridColumn.CellTemplate) is not exported.
Use the following methods to export the control's data to XLSX format:
- 
DataGridControl.ExportToXlsx(string fileName, XlsxExportOptions? options = null)— Exports data to a file.
- 
DataGridControl.ExportToXlsx(Stream stream, XlsxExportOptions? options = null)— Exports data to a stream.
The optional options parameter (of type XlsxExportOptions) allows you to customize export settings. The XlsxExportOptions class exposes the following members:
- ExportProgressevent — Fires repeatedly during data export. The event's- ExportProgressEventArgs.ProgressPercentageparameter indicates the progress as a percentage (0 to 100). You can use this event to display export progress to users in a customized way.
- 
AllowFixedColumnHeaderPanelproperty (default istrue) — Gets or sets whether the column header panel remains fixed at the top in the exported document.
- 
ApplyFormattingToEntireColumn— Gets or sets whether cell formatting is applied to entire columns or individual cells in the output document.
- 
AllowGroupingproperty (default istrue) — Gets or sets whether group rows and the group hierarchy are exported. IfAllowGroupingisfalse, data rows are only exported.
- 
DocumentCulture— Gets or sets a customCultureInfoobject that determines formatting rules for numeric and date-time values in the output document.If the DocumentCultureproperty is not specified, the export engine uses the application's current culture.
- 
ShowBandsproperty (default isnull) — Gets or sets whether the control's bands are included in the export.If ShowBandsisnull, the setting is specified by the control'sDataGridControl.ShowBandsproperty.
- 
ShowColumnHeadersproperty (default isnull) — Gets or sets whether the column header panel is included in the export.If ShowColumnHeadersisnull, the setting is specified by the control'sDataGridControl.ShowColumnHeadersproperty.
- 
ShowHorizontalLines— Gets or sets whether horizontal lines between cells are visible in the output document.
- 
ShowVerticalLines— Gets or sets whether vertical lines between cells are visible in the output document.
- 
TextExportModeproperty — Gets or sets default export mode of cell values.Available options include: - TextExportMode.Value— Exports cell values. If cell values are formatted in the DataGrid control, the export engine attempts to apply matching formatting to the exported values in the output document.
- TextExportMode.Text— Exports cell display text. If cell values are formatted in the DataGrid control, the formatted string representation is exported.
 You can use the GridColumn.TextExportModeproperty to override theXlsxExportOptions.TextExportModesetting for individual columns.Note The export engine only takes into account cell formatting applied using the GridColumn.EditorPropertiesproperty. For example:<mxdg:GridColumn Width="*" FieldName="Salary"> <mxdg:GridColumn.EditorProperties> <mxe:TextEditorProperties DisplayFormatString="c"/> </mxdg:GridColumn.EditorProperties> </mxdg:GridColumn>Cell formatting applied using other approaches (for instance, with GridColumn.CellTemplate) is ignored during data export.
Export to PDF Format¶
The PDF rendering engine follows the WYSIWYG concept, which retains the layout of grid elements in the output document.

Use the following methods to export the control's data to PDF format:
- 
DataGridControl.ExportToPdf(string fileName, PageExportOptions? options = null)— Exports data to a file.
- 
DataGridControl.ExportToPdf(Stream stream, PageExportOptions? options = null)— Exports data to a stream.
The optional options parameter (of type PageExportOptions) allows you to customize export settings. The PageExportOptions class exposes the following members:
- 
PageExportOptions.ExportProgressevent — Fires repeatedly during data export. The event'sExportProgressEventArgs.ProgressPercentageparameter indicates the progress as a percentage (0 to 100). You can use this event to display export progress to users in a customized way.
- 
PageExportOptions.FitToPageWidth(default isfalse) — Gets or sets whether grid columns are stretched to fit the paper width.
- 
PageExportOptions.Landscape(default isfalse) — Gets or sets whether the page orientation is horizontal (Landscape) or vertical (Portrait).
- 
PageExportOptions.Margins(default is72,72,72,72) — Gets or sets the page margins, in points. 1 point = 1/72 inch.
- 
PageExportOptions.PaperKind(default isA4) — Gets or sets the paper size.
- 
ShowBandsproperty (default isnull) — Gets or sets whether the control's bands are included in the export.If ShowBandsisnull, the setting is specified by the control'sDataGridControl.ShowBandsproperty.
- 
ShowColumnHeadersproperty (default isnull) — Gets or sets whether the column header panel is included in the export.If ShowColumnHeadersisnull, the setting is specified by the control'sDataGridControl.ShowColumnHeadersproperty.