Export Overview
LyteNyte Grid exports structured grid data to create files in various formats or to copy to the clipboard.
LyteNyte Grid supports custom file generation via the exportData
method, letting you support any file format without adding to the
core library’s size or complexity.
Export Data
The exportData method exports a rectangular area of data from the grid. This rectangular
area is defined by a start and end column and a start and end row, with the end values
being exclusive. The rectangle interface is shown below.
interface DataRect { readonly rowStart: number; readonly rowEnd: number; readonly columnStart: number; readonly columnEnd: number;}If you call exportData without any arguments, the grid exports data for a rectangle that
covers the entire grid. The examples below show the two ways to call exportData.
// Export a specific area of the grid.api.exportData({ rect: { columnStart: 2, columnEnd: 10, rowStart: 2, rowEnd: 8 } });
// Export everything.api.exportData();The exportData method returns a Promise<ExportDataRectResult> object. The interface for
this result is shown below. Each property on ExportDataRectResult is an array, and the
length of each array matches the size of the requested rectangle. LyteNyte Grid performs
the work of returning only the data for the requested columns and rows.
interface ExportDataRectResult<Spec extends GridSpec = GridSpec> { readonly headers: string[]; readonly groupHeaders: (string | null)[][]; readonly data: unknown[][]; readonly columns: Column<Spec>[];}Export Files
Use exportData primarily for file exports, though the API supports broader
data extraction tasks. For format-specific implementations, see the guides below:
Next Steps
- CSV Data Export: Export grid data as a CSV file.
- Clipboard: Copy and paste grid data using the clipboard.
- Export Excel: Implement Excel export using libraries like ExcelJS.
