LyteNyte Grid enables you to export grid data directly to CSV format. This feature helps you quickly extract data snippets or the entire dataset currently visible in your grid.
The LyteNyte Grid API provides the exportCsv
method to export selected data or the entire rendered
dataset.
The exportCsv
method returns a Promise<string>
containing the CSV content. When exporting a
selection, you can specify any rectangular area, not just the currently selected region. For example:
grid.api.exportCsv({
dataRect: { rowStart: 2, rowEnd: 4, columnEnd: 2, columnStart: 4 },
});
The exportCsv
method accepts a delimiter parameter to separate CSV data. The default delimiter
is a comma (,
).
By default, the exportCsv
method exports only data cells. Set the includeHeaders
property to
true
to include column headers in the output. Similarly, set the includeGroupHeaders
property to
true
to include group headers in the export.
Since group headers typically span multiple columns, the default behavior places the header in the
first column and leaves remaining spanned columns blank in the CSV output. Use the
uniformGroupHeaders
property to repeat group headers across all columns they span. This creates
perfectly rectangular data.
The exportCsv
method accepts a transform
parameter that lets you process rows before converting
them to CSV format. This helps you pre-process data before the final export.
A common use case involves downloading the CSV as a file. LyteNyte Grid's API provides a convenience
method called exportCsvFile
that works like exportCsv
but converts the CSV data to a
downloadable file blob.