How do you export data from a DevExpress grid, and what are the options?

DevExpress Data Grid Intermediate 1–2 Yrs2–3 Yrs3–5 Yrs Conceptual 1 min read

Quick Answer

The grid views expose ExportToXlsx, ExportToXls, ExportToPdf, ExportToCsv, ExportToHtml, etc. You choose between exporting the display (what's on screen — grouping, formatting, summaries) or the data (raw values). Export options control whether filters, grouping, and the filter row are respected.

The views have built-in export methods — ExportToXlsx, ExportToPdf, ExportToCsv and so on. The main decision is whether you export the display or the data. Exporting the display gives you the grouping, the formatting and the summary rows, which is what you want for a report handed to a user. Exporting data-aware gives you the raw typed values, which is what you want if the file is going to be processed further. You also set options for whether the current filter and sort are applied. The thing to watch is large data in server mode — a full export pulls every row, so for big sets I'd export from the underlying query instead of the grid.

  • WinForms: gridControl1.ExportToXlsx(path) or gridView1.ExportToXlsx(stream, new XlsxExportOptionsEx { ExportMode = ExportMode.SingleFile }).
  • Export display vs data — ExportMode.DataAware exports true typed values (good for further processing); the default exports the formatted display including grouping and summaries (good for a report).
  • Options: ShowGridLines, SheetName, RawDataMode, whether to export the current filter/sort.
  • Server mode — exporting normally streams all rows, which can be heavy; use the data-aware export and page through, or export from the source query directly for very large sets.
  • ASP.NET / DevExtreme grids have equivalent server-side export endpoints.