Export

Any Data Export

Grids can be exported in many formats. LyteNyte Grid includes built-in CSV export, but it does not bundle every format to avoid increasing file size. Instead, it offers the exportDataRect API method, which lets you export grid data in any format you choose.

Export Data Rect

Call exportDataRect from the grid's API to export selected rows and columns or the entire grid. The method returns either an ExportDataRectResult or a Promise<ExportDataRectResult>.

ExportDataRectResult Structure

interface ExportDataRectResult {
  readonly headers: string[];
  readonly groupHeaders: (string | null)[][];
  readonly data: unknown[][];
  readonly columns: ColumnPro[];
}
  • headers - Header label values for each column in the export range.
  • groupHeaders - Header labels of column groups in the export range.
  • data - Two-dimensional array containing the exported row data.
  • columns - Column definitions for the exported columns.

Example

grid.api.exportDataRect({
  dataRect: { rowStart: 0, rowEnd: 10, columnStart: 0, columnEnd: 20 },
});

Uniform Group Headers

When exporting columns that belong to a multi-column header group, exportDataRect returns the group header only for the first column in the group by default. To repeat the header group label across all columns it spans, set uniformGroupHeaders to true.

grid.api.exportDataRect({
  dataRect: { rowStart: 0, rowEnd: 10, columnStart: 0, columnEnd: 20 },
  uniformGroupHeaders: true,
});