Vue Data Grid: CSV Export
The grid data can be exported to CSV with an API call, or using the right-click context menu (Enterprise only) on the Grid.
What Gets Exported
The same data that is in the grid gets exported, but none of the GUI representation of the data will be. What this means is:
-
The raw values, and not the result of cell renderer will get used, meaning:
- Value Getters will be used.
- Cell Renderers will NOT be used.
- Cell Formatters will NOT be used (use
processCellCallbackinstead).
- Cell styles are not exported.
-
If row grouping:
- All data will be exported regardless of whether groups are open in the UI.
- By default, group names will be in the format "-> Parent Name -> Child Name" (use
processRowGroupCallbackto change this). - Row group footers (
groupIncludeFooter=true) will NOT be exported - this is a GUI addition only.
The CSV export will be enabled by default. If you want to disable it, you can set the property suppressCsvExport = true in your gridOptions.
Standard Export
The example below shows the default behaviour when exporting the grid's data to CSV.
Note the following:
- You can use the
Show CSV export content textbutton, to preview the output. - You can use the
Download CSV export filebutton to download a csv file. - The file will be exported using the default name:
export.csv. - Community version supports api CSV Export but not Context Menu.
Changing the column separator
By default, a CSV file separates its columns using ,. But this value token could be changed using the columnSeparator param.
Note the following:
- You can use the select field at the top to switch the value of the
columnSeparatorparam. - You can use the
Show CSV export content textbutton, to preview the output. - Enterprise version enables CSV Export using right click via the Context Menu.
Suppress Quotes
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 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.
Note the following:
- You can use the select field at the top to switch the value of the
suppressQuotesparam. - You can edit the cells to preview the results with different inputs.
- You can use the
Show CSV export content textbutton, to preview the output. - You can use the
Download CSV export filebutton to download a csv file.
Prepending and Appending Content
The recommended way to prepend or append content, is by passing an array of CsvCell objects to appendContent or prependContent. This ensures that your content is correctly escaped.
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.
Note the following:
-
You can use select fields at the top to switch the value of
prependContentandappendContent.- With
prependContent=CsvCell[][]orappendContent=CsvCell[][], 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. - With
prependContent=stringorappendContent=string, 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 that will not be visible in Excel.
- With
- You can use the
Show CSV export content textbutton, to preview the output. - You can use the
Download CSV export filebutton to download a csv file.
Column Headers
In some situations, you could be interested in exporting only the grid data, without exporting the header cells. For this scenario, we provide the skipColumnGroupHeaders=true and skipColumnHeaders=true params.
Note the following:
- Initially, grouped headers and header are exported.
- Group Headers will be skipped if
Skip Column Group Headersis checked. - Normal headers will be skipped if
Skip Column Headersis checked.
Pinned Rows
If the pinned rows are not relevant to the data, they can be excluded from the export by using the skipPinnedTop=true and skipPinnedBottom=true params.
Note the following:
- By default, all pinned rows are exported.
- If
Skip Pinned Top Rowsis checked, the rows pinned at the top will be skipped. - If
Skip Pinned Bottom Rowsis checked, the rows pinned at the bottom will be skipped.
Hidden Columns
By default, hidden columns are not exported. If you would like all columns to be exported regardless of the current state of grid, use the allColumns=true params.
Note the following:
- By default, only visible columns will be exported. The bronze, silver, and gold columns will not.
- If
Export All Columnsis checked, the bronze, silver, and gold columns will be included in the export.