Skip to main content

csv()

Exports data from a grid into a CSV file

csv(config?: ICsvExportConfig) => Promise<string>;

Parameters:

  • config - (optional) an object with export settings. You can specify the following settings for export to CSV:
    • asFile?: boolean - (optional) defines whether Grid should be exported to a file, true by default. To export Grid only as a CSV string, you need to set asFile:false
    • name?: string - (optional) "grid" by default. The name of the exported CSV file (if asFile is not set to false)
    • rowDelimiter?: string - (optional) a newline ("\n") by default. A separator between rows, can be a tab - "\t", or any other value
    • columnDelimiter?: string - (optional) a comma (",") by default. A separator between columns, can be a semicolon - ";", or any other value
note

You can specify extended export configuration settings via the Grid exportConfig configuration property.

Returns:

A promise of data export as a CSV string

Example

// default export
grid.export.csv()
.then(() => console.log("success"))
.catch(() => console.log("failure"))
.finally(() => console.log("finished"));

// export with config settings
grid.export.csv({
name: "my_file", // the name of a ready CSV file
rowDelimiter: "\t", // the delimiter used to separate rows
columnDelimiter: ";" // the delimiter used to separate columns
})
.then(() => console.log("success"))
.catch(() => console.log("failure"))
.finally(() => console.log("finished"));

Related samples: Grid. Export to xlsx and csv

Related article: Exporting Grid

Change log:

  • The method returns a promise of data export since v9.3