Skip to content

Instantly share code, notes, and snippets.

@Takas0522
Created June 15, 2017 03:14
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 Takas0522/3c771cd25febd3586e2ebd76265257dd to your computer and use it in GitHub Desktop.
Save Takas0522/3c771cd25febd3586e2ebd76265257dd to your computer and use it in GitHub Desktop.
component - CSVをエクスポートするやつ
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