Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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