【发布时间】:2020-10-29 13:08:15
【问题描述】:
我的项目使用 angular,现在调用 api 来获取 excel 文件的 byte[]。但是当我通过 blob 将 byte[] 转换为文件时,该文件已损坏。有人可以帮我吗
我的 Angular 是第 9 版
service.ts:
downloadFile(req?: any): any {
const options = createRequestOption(req);
return this.http.get(`${this.resourceUrl}/print`, {
params: options,
responseType:'blob' })
.toPromise();
}
component.ts:
import {saveAs} from 'file-saver';
export():void{
this.exportService.downloadFile({}) .then((blob:any)=> {
saveAs(blob, 'test.xlsx');
});
}
}
【问题讨论】:
标签: arrays angular typescript blob export-to-excel