Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSV export is missing formatting options to be useful #41

Open
savar opened this issue Apr 16, 2024 · 0 comments
Open

CSV export is missing formatting options to be useful #41

savar opened this issue Apr 16, 2024 · 0 comments

Comments

@savar
Copy link

savar commented Apr 16, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant