1 public Down(path: string) { 2 3 return this.http.get(path, { responseType: "blob" }).subscribe((results) => { 4 5 this.saveExcel(results, "导出数据"); 6 }); 7 8 } 9 10/** 11 * 请求成功之后保存成excel文件(基本导出方法,请求成功之后调用) 12 * @param data 13 * @param name 14 */ 15 public saveExcel(data: Blob, name: string) { 16 var a = document.createElement('a'); 17 var blob = new Blob([data], { 'type': "application/vnd.ms-excel" }); 18 a.href = URL.createObjectURL(blob); 19 a.download = name + ".csv"; 20 a.click(); 21 }
Angular下载文件
Stella981
2021-10-11
1304 0 0
点赞
收藏
评论区
加载中...