Angular5 UI post 請求 輸出 檔案下載
阿新 • • 發佈:2018-11-11
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(View Code'download', 'Inventory' + new Date().getTime() + '.xls'); link.style.visibility = 'hidden'; document.body.appendChild(link); link.click(); document.body.removeChild(link); }); }