The data can be exported to CSV with an API call, or using the right-click context menu on the Grid.
gridOptions.suppressCsvExport: set this Grid Property to true to disable CSV export
exportDataAsCsv(params): download a CSV file to the user's computer.
getDataAsCsv(params): return a CSV string.
The params object can contain all the common export options, as well as these CSV-specific options:
By default cell values are encoded according to CSV format rules: values are wrapped in double quotes, and any
double quotes within the values are escaped, so
|columnSeparator||Delimiter to insert between cell values. Defaults to comma.|
Appending header and footer content
The recommended way to append header and footer content is by passing an array of
ExcelCell objects to
customFooter, as described in the
Export documentation. This ensures that your
header content is correctly escaped, and if your application also exports Excel data you
can use the same data for both exports.
For compatibility with earlier versions of the Grid you can also pass a string, which will be inserted into the CSV file without any processing. You are responsible for formatting the string according to the CSV standard.
Example: CSV Export Options
columnSeparatorhave the effects documented above. Use the "api.getTextAsCsv()" button to see their effect, because changing their default values will prevent the file from opening properly in Excel
customHeader=ExcelCell, custom content will be inserted containing commas and quotes. These commas and quotes will be visible when opened in Excel because they have been escaped properly.
customHeader=stringcauses a string to be inserted into the CSV file without any processing, and without being affected by
columnSeparator. It contains commas and quotes what will not be visible in Excel.