CSV Export

The data can be exported to CSV with an API call, or using the right-click context menu on the Grid.

This page covers CSV-specific features. For information on how to control what data is included in the export and to format/transform the data as it is exported, see the Export documentation.

API

Grid Properties

suppressCsvExportPrevents the user from exporting the grid to CSV.
Default: false

Grid API

exportDataAsCsv(params)Downloads a CSV export of the grid's data.
getDataAsCsv(params)Similar to exportDataAsCsv, except returns the result as a string rather than download it.

The params object can contain all the common export options, as well as these CSV-specific options:

suppressQuotesBy 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 my"value becomes "my""value". Pass true to insert the value into the CSV file without escaping. In this case it is your responsibility to ensure that no cells contain the columnSeparator character.
Default: false
columnSeparatorDelimiter to insert between cell values.
Default: ','

Appending header and footer content

The recommended way to append header and footer content is by passing an array of ExcelCell objects to customHeader or 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

  • suppressQuotes and columnSeparator have 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
  • With 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.
  • Setting customHeader=string causes a string to be inserted into the CSV file without any processing, and without being affected by suppressQuotes and columnSeparator. It contains commas and quotes what will not be visible in Excel.