This repository has been archived on 2025-12-21. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
2025-06-26 13:09:12 -04:00

14 lines
486 B
TypeScript

export function exportToCsv(filename: string, rows: any[]) {
if (!rows.length) return;
const keys = Object.keys(rows[0]);
const csv = keys.join(',') + '\\n' +
rows.map(r => keys.map(k => JSON.stringify(r[k] || '')).join(',')).join('\\n');
const blob = new Blob([csv], { type: 'text/csv' });
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = filename;
document.body.appendChild(link);
link.click();
link.remove();
}