A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.ag-grid.com/javascript-data-grid/csv-export/ below:

JavaScript Grid: CSV Export | AG Grid

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 Copy Link

The same data that is in the grid gets exported, with some of the GUI representation of the data. What this means is:

The CSV export will be enabled by default. If you want to disable it, you can set the property suppressCsvExport = true in your gridOptions.

Security Concerns Copy Link

When opening CSV files, spreadsheet applications like Excel, Apple Numbers, Google Sheets and others will automatically execute cell values that start with the following symbols as formulas: +, -, =, @, Tab (0x09) and Carriage Return (0x0D). In order to prevent any malicious content from being exported we recommend using the callback methods shown in the CSV Export Params to modify the exported cell values so that they do NOT start with any of the characters listed above. This way the applications will not execute the cell value directly if it starts with the characters listed above. If you'd like to keep the cell values unchanged when exporting, please allow exporting to Excel only.

Standard Export Copy Link

The example below shows the default behaviour when exporting the grid's data to CSV.

Note the following:

Changing the column separator Copy Link

By default, a CSV file separates its columns using ,. But this value token could be changed using the columnSeparator param.

Note the following:

Suppress Quotes Copy Link

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:

Prepending and Appending Content Copy Link

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:

Column Headers Copy Link

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:

Pinned Rows Copy Link

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, 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:

API Copy Link Grid Properties Copy Link CsvExportParams

A default configuration object used to export to CSV.

CsvExportModule

boolean

default: false

Prevents the user from exporting the grid to CSV.

API Methods Copy Link

Function

Downloads a CSV export of the grid's data.

CsvExportModule

Function

Similar to exportDataAsCsv, except returns the result as a string rather than download it.

CsvExportModule Interfaces Copy Link CsvExportParams Copy Link

Properties available on the CsvExportParams interface.

columnSeparatorCopy Link

string

default: ,

Delimiter to insert between cell values.

boolean

default: false

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.

CsvCustomContent

Content to put at the top of the file export. A 2D array of CsvCell objects (see

Prepending and Appending Content

). Alternatively, you can pass a multi-line string that is simply appended to the top of the file content.

CsvCustomContent

Content to put at the bottom of the file export. A 2D array of CsvCell objects (see

Prepending and Appending Content

). Alternatively, you can pass a multi-line string that is simply appended to the bottom of the file content.

Function

A callback function to return content to be inserted below a row in the export.

boolean

Set to true to allow the contents of the Header Row Column to be exported.

allColumnsCopy Link

boolean

default: false

If true, all columns will be exported in the order they appear in the columnDefs. When false only the columns currently being displayed will be exported.

columnKeysCopy Link

(string | Column)[]

Provide a list (an array) of column keys or Column objects if you want to export specific columns.

RowPosition[]

Row node positions.

string | ExportFileNameGetter

default: export.csv

String to use as the file name or a function that returns a string.

'all' | 'filteredAndSorted'

default: 'filteredAndSorted'

Determines whether rows are exported before being filtered and sorted.

boolean

default: false

Export only selected rows.

boolean

default: false

Only export selected rows including other pages (only makes sense when using pagination).

skipColumnGroupHeadersCopy Link

boolean

default: false

Set to true to exclude header column groups.

skipColumnHeadersCopy Link

boolean

default: false

Set to true if you don't want to export column headers.

boolean

default: false

Set to true to skip row group headers if grouping rows. Only relevant when grouping rows.

boolean

default: false

Set to true to suppress exporting rows pinned to the top of the grid.

boolean

default: false

Set to true to suppress exporting rows pinned to the bottom of the grid.

Function

A callback function that will be invoked once per row in the grid. Return true to omit the row from the export.

Function

A callback function invoked once per cell in the grid. Return a string value to be displayed in the export. For example this is useful for formatting date values.

Function

A callback function invoked once per column. Return a string to be displayed in the column header.

Function

A callback function invoked once per column group. Return a string to be displayed in the column group header. Note that column groups are exported by default, this option will not work with skipColumnGroupHeaders=true.

Function

A callback function invoked once per row group. Return a string to be displayed in the group cell.

CsvCell Copy Link

Properties available on the CsvCell interface.

CsvCellData

The data that will be added to the cell.

number

default: 0

The number of cells to span across (1 means span 2 columns).

CsvCellData Copy Link

Properties available on the CsvCellData interface.

string | null

The value of the cell.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4