CSV Export Basics
The csv property of the Grid component enables you to export the content of the KendoReact Data Grid to CSV format using the built-in @progress/kendo-csv library and @progress/kendo-file-saver for file saving.
Getting Started
To enable CSV export in the Grid:
- Set the Grid
csvprop totrueor provide aGridCSVExportOptionsconfiguration object. - Add the
GridCsvExportButtoncomponent to the Grid toolbar or use a custom button.
The following example demonstrates the basic CSV export functionality. The Grid uses autoProcessData={true} to handle pagination internally, and with csv={true}, clicking the export button exports all data by default:
Note: When using
autoProcessData={true}, theallPagesoption controls pagination behavior during export. By defaultallPagesistrue, which exports all data. SetallPages: falseto export only the current page. See the Basic Configuration Example below for more details.
CSV Export Options
The CSV export functionality provides extensive customization through the GridCSVExportOptions interface:
- allPages - Exports all pages or only the current page (default:
true- exports all data) - fileName - Sets the name of the exported CSV file (default: "grid-export.csv")
- data - Optional custom data to export instead of Grid's data
- keys - Specifies which properties to export from the data objects
- names - Defines custom header names for the exported columns
- delimiter - Sets the character used to separate values (default: ",")
- lineSeparator - Defines the line ending character (default: "\r\n")
- preventFormulaInjection - Protects against formula injection attacks (default: true)
- maxCellLength - Sets the maximum character length per cell (default: 32767)
- includeUTF8BOM - Adds UTF-8 BOM for better Excel compatibility with special characters
Basic Configuration Example
The following example demonstrates how to export all data while displaying only a paginated view. The Grid shows 10 items per page, but with allPages: true (the default), the CSV export includes all products with a custom file name (products-export.csv) and Unix-style line endings:
CSV Export Features
- Customizing exported columns
- Exporting custom data
- Exporting grouped data
- Programmatic export (saveAsCsv & getCsvBlob)
- Data transformation with onCsvExport
- Formula injection protection