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
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Collapse]Pivot Grid
   [Expand]Getting Started
   [Expand]Fundamentals
   [Expand]Binding to Data
   [Expand]Data Shaping
   [Expand]Data Analysis
   [Expand]Layout
   [Expand]Focus and Navigation
   [Collapse]Printing and Exporting
     Printing
     Exporting
   [Expand]Appearance
   [Expand]Design-time Features
   [Expand]Miscellaneous
   [Expand]UI Elements
   [Expand]End-User Capabilities
   [Expand]Examples
   [Expand]Member Tables
  [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

Exporting

The Pivot Grid control allows you to export the Pivot Grid's data to a file or stream in various formats - HTML, MHT, PDF, RTF, TXT, CSV, XLS or XLSX. When you export, you copy data from a pivot grid into a new file formatted for use in another application. This document describes export in detail.

To export the pivot grid's data, use one of the following export methods.

Output Format Methods Data-Aware Support Description
HTML PivotGridControl.ExportToHtml n/a Exports Pivot Grid data to the specified file in HTML format, using the specified character encoding.
MHT PivotGridControl.ExportToMht n/a Exports Pivot Grid data to the specified file in an MHT format using the specified character encoding with the specified title. The output file can be compressed (secondary characters such as spaces are removed) if required.
PDF PivotGridControl.ExportToPdf n/a Exports Pivot Grid data to the specified file in PDF format.
RTF PivotGridControl.ExportToRtf n/a Exports Pivot Grid data to the specified file in RTF format.
TXT PivotGridControl.ExportToText n/a Exports Pivot Grid data to the specified file in TXT format, using the specified separator string and encoding settings.
CSV PivotGridControl.ExportToCsv Exports the Pivot Grid data to the specified file in CSV format.
XLS PivotGridControl.ExportToXls Exports Pivot Grid data to the specified file in XLS format using the specified options.
XLSX PivotGridControl.ExportToXlsx Exports Pivot Grid data to the specified file in XLSX (MS Excel 2007) format using the specified options.

Export settings can be customized when calling the ExportTo... method overloads that take an options parameter. This parameter can be specified with a descendant of the ExportOptionsBase class that defines how a document is exported to the specific format.

Note

Results of custom drawing and images cannot be exported.

Expanded Export Modes

Two export modes are supported when exporting data from a Pivot Grid control to table formats (*.xls(x), *.csv).

  • Data-aware Export - The export mode, optimized for subsequent analysis of pivot grid data within Microsoft Excel. Various data shaping options that are applied within the pivot grid are retained in the output XLS(X) and CSV documents.
  • WYSIWYG Export - In this export mode, the layout of pivot grid cells is retained in resulting XLS(X) and CSV documents. Specific data shaping options are not retained, compared to data-aware export.

Data exported using other formats (PDF, RTF, TXT, etc.) are always exported in the WYSIWYG mode.

Choosing Export Mode

You can specify export mode in two ways.

  • Set the ExportSettings.DefaultExportType static property that allows you to choose the required export mode used by default by all XLS(X) and CSV export methods.
  • Specify export mode with each call of the XLS(X) or CSV export methods (when using these method overloads with an options parameter). Create an PivotXlsExportOptions object (or PivotXlsxExportOptions, CsvExportOptionsEx objects), set its ExportType property and pass this object to the XLS(X)/CSV export method.

Expanded Data-Aware Export

Data-aware is the default export mode for XLS and XLSX formats, and optimized for subsequent analysis of pivot grid data within Microsoft Excel.

The following data shaping options that are applied within the pivot grid control are retained in the output XLS-XLSX documents.

  • Data Grouping - with the capability to collapse/expand groups within a worksheet.
  • Fixed Columns - column and row areas stay in sight.
  • Cells Formatting - exporting the number format.
  • Display Text/Value export - the capability to select whether to export display text or values.

Data-Aware Export Settings

A few options that are inherited by the XlsExportOptionsEx and XlsxExportOptionsEx classes from their base class are not supported by the data-aware export engine. The options supported in data-aware mode are listed in the following table.

Property Description
XlExportOptionsBase.SheetName Gets or sets the name of a sheet in a created XLS file, to which a document is exported.
XlsExportOptionsEx.AllowFixedColumns
XlsxExportOptionsEx.AllowFixedColumns
Gets or sets whether the row area in a pivot grid control is fixed in the exported document.
XlsExportOptionsEx.AllowFixedColumnHeaderPanel
XlsxExportOptionsEx.AllowFixedColumnHeaderPanel
Gets or sets whether the column area is anchored to the top of the export document, and thus is not scrolled vertically.
XlsExportOptionsEx.AllowGrouping
XlsxExportOptionsEx.AllowGrouping
Gets or sets whether data groups are exported from the source control to the output document.
XlsExportOptionsEx.ShowPageTitle
XlsxExportOptionsEx.ShowPageTitle
Gets or sets whether a title is displayed for each print preview page of the exported document.
XlsExportOptionsEx.ExportType
XlsxExportOptionsEx.ExportType
Gets or sets export mode. You can specify WYSIWYG or data-aware export mode.
XlsExportOptionsEx.GroupState
XlsxExportOptionsEx.GroupState
Gets or sets whether groups will be collapsed or expanded in the exported document.
XlExportOptionsBase.RawDataMode Enables the export mode, which when used, exports only a report's actual data to XLS(X). Note that options like XlsExportOptionsEx.AllowGrouping and XlsxExportOptionsEx.AllowGrouping are disabled and not in effect in the exported document. Note that the parent cell value in the exported document are exported for every child cell value when the RawDataMode property is set to true.
XlExportOptionsBase.TextExportMode Gets or sets a value indicating whether the cells in the resulting XLS(X) document should use the same formatting as the original document.

You can customize a PivotGrid's cell in the exported XLS or XLSX document using the PivotXlsExportOptions.CustomizeCell and PivotXlsxExportOptions.CustomizeCell events. Use the CustomizePivotCellEventArgs.RowType and CustomizePivotCellEventArgs.ColumnType parameters to identify a row and column containing the cell. To specify the cell location in the exported Excel document, use the CustomizePivotCellEventArgs.ExportArea property. To customize the cell format, use the CustomizePivotCellEventArgs.Formatting property.

Note

Set the CustomizePivotCellEventArgs.Handled parameter to true to export cells with custom formatting.

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