Skip to content

Instantly share code, notes, and snippets.

@buhichan
Created July 17, 2017 06:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save buhichan/28a6d904939583074355939797c1d7cf to your computer and use it in GitHub Desktop.
Save buhichan/28a6d904939583074355939797c1d7cf to your computer and use it in GitHub Desktop.
exportAsCSV,timeRange,etc.
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