如何使用angular 2从本地目录下载csv文件

时间:2018-11-13 12:09:54

标签: angular

this._reportService.getReport().subscribe(data => 
this.downloadFile(data)),//console.log(data),
                  error => console.log("Error downloading the file."),
                  () => console.info("OK");

请求准备就绪后,它将调用函数“ downloadFile”

downloadFile(data: Response){ 
   var blob = new Blob([data], { type: 'text/csv' });
   var url= window.URL.createObjectURL(blob);
  window.open(url);

}

import 'rxjs/Rx' ;

它不起作用,请帮助

0 个答案:

没有答案