Export & Clipboard
CSV Data Export
Export grid data to CSV using LyteNyte Grid's export API.
Generate CSV files by parsing the structured output of
the exportData API method.
CSV Download
The demo below exports grid data to a CSV string, then downloads it as a CSV file.
The example below demonstrates a basic CSV export implementation. For robust serialization that handles all edge cases, use a dedicated library like csv-parser.
<button data-ln-button="tertiary" data-ln-size="md" onClick={async () => { const api = apiRef.current; if (!api) return;
const rect = await api.exportData();
const rows: string[] = [rect.columns.map((x) => x.name ?? x.id).join(",")]; for (let i = 0; i < rect.data.length; i++) { const row: string[] = []; const data = rect.data[i]; for (const x of data) { if (typeof x === "string") row.push(`"${x}"`); else row.push(String(x)); } rows.push(row.join(",")); }
downloadBlob(new Blob([rows.join("\n")], { type: "text/csv" }), "data.csv"); }}> Download CSV File</button>Next Steps
- Clipboard: Copy and paste grid data using the clipboard.
- Export Excel: Implement Excel export using libraries like ExcelJS.
- Export Parquet: Export grid data as a Parquet file.
