CSV writefile delimiter change based on region #2923

Open
opened 2023-04-18 22:28:37 +00:00 by MrShaneH · 1 comment

My app has a basic "export to CSV" feature that takes users data in JSON format from an API endpoint and writes to an export.csv file.

const worksheet = utils.json_to_sheet(jsonData, { cellDates: true });
const workbook = utils.book_new();
utils.book_append_sheet(workbook, worksheet, "data");
writeFile(workbook, 'export.csv', { bookType: 'csv' })

This works well for users in regions where the delimiter is a comma.
However some users are in regions where the comma is used as the decimal in price information e.g. €5,78 and there the delimiter is the semicolon.

Is this handled natively by, say, using browser detection or should I do the detection in code and use utils.sheet_to_csv setting FS value manually?

Thanks

My app has a basic "export to CSV" feature that takes users data in JSON format from an API endpoint and writes to an export.csv file. ``` const worksheet = utils.json_to_sheet(jsonData, { cellDates: true }); const workbook = utils.book_new(); utils.book_append_sheet(workbook, worksheet, "data"); writeFile(workbook, 'export.csv', { bookType: 'csv' }) ``` This works well for users in regions where the delimiter is a comma. However some users are in regions where the comma is used as the decimal in price information e.g. €5,78 and there the delimiter is the semicolon. Is this handled natively by, say, using browser detection or should I do the detection in code and use utils.sheet_to_csv setting FS value manually? Thanks
Owner

Currently there is no logic for auto-detecting the user locale settings. This is feasible and is planned before our 1.0 release.

Currently there is no logic for auto-detecting the user locale settings. This is feasible and is planned before our 1.0 release.
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/sheetjs#2923
No description provided.