Created
July 17, 2017 06:04
-
-
Save buhichan/28a6d904939583074355939797c1d7cf to your computer and use it in GitHub Desktop.
exportAsCSV,timeRange,etc.
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 $exportCSV(csv, filename) { | |
const blobObject = new Blob(["\ufeff", csv], { | |
type: "text/csv;charset=utf-8;" | |
}); | |
// Internet Explorer | |
if (navigator.msSaveOrOpenBlob) { | |
navigator.msSaveOrOpenBlob(blobObject, filename); | |
} else { | |
// Chrome | |
const downloadLink = document.createElement("a"); | |
downloadLink.href = URL.createObjectURL(blobObject); | |
downloadLink.download = filename; | |
document.body.appendChild(downloadLink); | |
downloadLink.click(); | |
document.body.removeChild(downloadLink); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment