Created
June 15, 2017 03:14
-
-
Save Takas0522/3c771cd25febd3586e2ebd76265257dd to your computer and use it in GitHub Desktop.
component - CSVをエクスポートするやつ
This file contains 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
private downloadFile(data: any) { | |
var blob = new Blob([(<any>data)], { type: "text/csv" }); | |
let csvFileName = "日本語ファイル名称.csv"; | |
if (window.navigator.msSaveOrOpenBlob) { | |
//IEの場合 | |
navigator.msSaveBlob(blob, csvFileName); | |
} else { | |
//IE以外(Chrome, Firefox) | |
let link = document.createElement("a"); | |
link.setAttribute("href", window.URL.createObjectURL(blob)); | |
link.setAttribute("download", csvFileName); | |
document.body.appendChild(link); | |
link.click(); | |
link.remove(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment