Angular5 UI post 请求 输出 文件下载

前端之家收集整理的这篇文章主要介绍了Angular5 UI post 请求 输出 文件下载前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

分享图片

  this.httpClient.post(url1,JSON.parse(data1),{responseType: blob}).subscribe(data => {
            const link = document.createElement(a);
            const blob = new Blob([data],{type: application/vnd.ms-excel});
            link.setAttribute(href,window.URL.createObjectURL(blob));
            link.setAttribute(download,Inventory + new Date().getTime() + .xls);
            link.style.visibility = hidden;
            document.body.appendChild(link);
            link.click();
            document.body.removeChild(link);
        });
    }
View Code

猜你在找的Angularjs相关文章