Export¶
Starting with version 1.2, the TreeList control can export data to XLSX (Microsoft Excel) format.
Note
Include the Eremex.DocumentProcessing library in your project to use the export feature.
Export to XLSX Format¶
The Excel export engine is data-aware, meaning it preserves the control's data shaping options in the output XLSX document, including:
- Node hierarchy
- 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 (TreeListColumn.CellTemplate
) is not exported.
Use the following methods to export the control's data to XLSX format:
-
TreeListControl.ExportToXlsx(string fileName, XlsxExportOptions? options = null)
— Exports data to a file. -
TreeListControl.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:
ExportProgress
event — Fires repeatedly during data export. The event'sExportProgressEventArgs.ProgressPercentage
parameter indicates the progress as a percentage (0 to 100). You can use this event to display export progress to users in a customized way.-
AllowFixedColumnHeaderPanel
property (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. -
AllowGrouping
property (default istrue
) — Gets or sets whether the node hierarchy is exported. IfAllowGrouping
isfalse
, the node hierarchy is not stored in the output document. -
DocumentCulture
— Gets or sets a customCultureInfo
object that determines formatting rules for numeric and date-time values in the output document.If the
DocumentCulture
property is not specified, the export engine uses the application's current culture. -
ShowBands
property (default isnull
) — Gets or sets whether the control's bands are included in the export.If
ShowBands
isnull
, the setting is specified by the control'sTreeListControl.ShowBands
property. -
ShowColumnHeaders
property (default isnull
) — Gets or sets whether the column header panel is included in the export.If
ShowColumnHeaders
isnull
, the setting is specified by the control'sTreeListControl.ShowColumnHeaders
property. -
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. -
TextExportMode
property — Gets or sets default export mode of cell values.Available options include:
TextExportMode.Value
— Exports cell values. If cell values are formatted in the TreeList 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 TreeList control, the formatted string representation is exported.
You can use the
TreeListColumn.TextExportMode
property to override theXlsxExportOptions.TextExportMode
setting for individual columns.Note
The export engine only takes into account cell formatting applied using the
TreeListColumn.EditorProperties
property. For example:<mxtl:TreeListColumn Width="*" FieldName="Salary"> <mxtl:TreeListColumn.EditorProperties> <mxe:TextEditorProperties DisplayFormatString="c"/> </mxtl:TreeListColumn.EditorProperties> </mxtl:TreeListColumn>
Cell formatting applied using other approaches (for instance, with
TreeListColumn.CellTemplate
) is ignored during data export.