How to download an excel file in Angular 8 as an API response

后端 未结 6 2547
长发绾君心
长发绾君心 2021-02-16 00:27

I\'ve an API which returns an excel document as response. The request will be one simple json.

I\'ve searched google and found some code base to download the file and I

6条回答
  •  滥情空心
    2021-02-16 00:32

    To download the file use the below code

    downloadFile(data: Response) {
      const blob = new Blob([data], { type: 'application/octet-stream' });
      fs.saveAs(blob, fileName + '.xlsx');
    }
    

提交回复
热议问题