在 angular 上保存 excel 文件时出现错误无法执行 createObjectURL?
when save excel file on angular 8 get error Failed to execute createObjectURL?
我在处理 angular 8
我在保存 excel 文件时遇到问题 我收到如下错误:
ERROR TypeError: Failed to execute 'createObjectURL' on 'URL': Overload resolution failed.
at Function.a [as saveAs] (FileSaver.min.js:1:1339)
at SafeSubscriber._next (zdeliverysys.component.ts:225:23)
我尝试的是:
component ts
this._dataService.PostUpload(this.fileToUpload)
.subscribe(blob => {
saveAs(blob.body, this.fileToUpload +'.xlsx');
});
service.ts
PostUpload( file:any):Observable<any>
{
const formData: FormData = new FormData();
formData.append('file', file,file.name);
return this.http.post(this.url + 'Z2Delivery/Upload' , formData,{responseType: 'blob' });
}
如何解决这个问题?
我解决了我的问题
我在 angular
上修改服务响应
来自
return this.http.post(this.url + 'Z2Delivery/Upload' , formData,{responseType: 'blob' });
至
return this.http.post(this.url + 'Z2Delivery/Upload' , formData,{observe: 'response',responseType: 'blob' });
和excel文件下载成功没有任何问题
我在处理 angular 8
我在保存 excel 文件时遇到问题 我收到如下错误:
ERROR TypeError: Failed to execute 'createObjectURL' on 'URL': Overload resolution failed.
at Function.a [as saveAs] (FileSaver.min.js:1:1339)
at SafeSubscriber._next (zdeliverysys.component.ts:225:23)
我尝试的是:
component ts
this._dataService.PostUpload(this.fileToUpload)
.subscribe(blob => {
saveAs(blob.body, this.fileToUpload +'.xlsx');
});
service.ts
PostUpload( file:any):Observable<any>
{
const formData: FormData = new FormData();
formData.append('file', file,file.name);
return this.http.post(this.url + 'Z2Delivery/Upload' , formData,{responseType: 'blob' });
}
如何解决这个问题?
我解决了我的问题 我在 angular
上修改服务响应来自
return this.http.post(this.url + 'Z2Delivery/Upload' , formData,{responseType: 'blob' });
至
return this.http.post(this.url + 'Z2Delivery/Upload' , formData,{observe: 'response',responseType: 'blob' });
和excel文件下载成功没有任何问题