Created
June 10, 2019 22:01
-
-
Save marco-souza/31f02d564bff8301e7b022608fd1abbf to your computer and use it in GitHub Desktop.
Download CSV form string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export function downloadCSV(CSVText, filename) { | |
| const link = document.createElement('a'); | |
| link.setAttribute('href', window.URL.createObjectURL( | |
| new Blob([CSVText]), | |
| { type: 'text/plain' } | |
| )); | |
| link.setAttribute('download', `${filename}.csv`); | |
| document.body.appendChild(link); // Required for FF | |
| link.click(); | |
| document.body.removeChild(link); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment