OvidijusParsiunas/active-table

CSV export is missing formatting options to be useful

Opened this issue · 0 comments

Hey, the CSV export is doing a simple join(',') on each row and a join('\n') on all rows.

CSV actually supports (depending on the flavour different things including specifying the delimiter, having quoted fields, even having newlines in quoted fields and so on and so on.

To be useful I would at least say that we need an option to quote all fields and therefore "escape" the " inside of a field..

https://github.com/OvidijusParsiunas/active-table/blob/main/component/src/utils/outerTableComponents/files/CSV/CSVExport.ts#L5

Example:

const csvData = 'data:text/csv;charset=utf-8,' + at.data.map((e) => '"' + e.map((d) => d.replaceAll('"', '""')).join('","') + '"').join('\n');

It would be probably nice to expose a generic options element to the buttons: [{ export: {} }] element, where you can configure this.