exportWordCase() { // 导出word
if (!this.suiteId) {
this.msg.error('请选择目录!');
return;
}
this.isSpinShow = true;
let url = this.url + 'v1/testrom/export/word?suiteId=' + this.suiteId;
this.http.get(url, '', { responseType: 'blob' }).subscribe((rest: any) => {
let blob = new Blob([rest], { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" });
//导出的格式为word
let objectUrl = URL.createObjectURL(blob);
let a = document.createElement('a');
let fileName = this.suiteName + '.docx';
document.body.appendChild(a);
a.setAttribute('style', 'display:none');
a.setAttribute('href', objectUrl);
a.setAttribute('download', fileName);
a.click();
URL.revokeObjectURL(objectUrl);
setTimeout(() => {
this.isSpinShow = false;
}, 2000);
});
}
angular: 前端TS把后台数据导出word格式
猜你喜欢
转载自blog.csdn.net/lengyuewusheng99/article/details/84256011
今日推荐
周排行