Skip to content

Commit

Permalink
Merge pull request #218 from Tampere/fix/csv-export
Browse files Browse the repository at this point in the history
Create csv link url from blob to allow special characters
  • Loading branch information
ossitammi authored Mar 26, 2024
2 parents 23db59c + 866c6cb commit 7cc718a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion client/src/components/admin/DataExport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ export default function DataExport({ surveyId }: Props) {
});

const csvText = await res.text();
const textBlob = new Blob([csvText], { type: 'text/csv;charset=utf-8' });

const link = document.createElement('a');
link.href = `data:text/csv;charset=utf-8,${encodeURI(csvText)}`;
link.href = URL.createObjectURL(textBlob);
link.target = '_blank';
link.download = 'data.csv';
link.click();
Expand Down

0 comments on commit 7cc718a

Please sign in to comment.