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.
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>
.
interface ExportDataRectResult {
readonly headers: string[];
readonly groupHeaders: (string | null)[][];
readonly data: unknown[][];
readonly columns: ColumnPro[];
}
grid.api.exportDataRect({
dataRect: { rowStart: 0, rowEnd: 10, columnStart: 0, columnEnd: 20 },
});
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,
});