我需要根据http帖子发送的标题设置导出的excel的名称。
这是我的代码:
component.ts
public getAccordo(event: any): any {
event.preventDefault();
this.accordiService.getAccordo(this.filter).subscribe(
data => {
const blob = new Blob([data], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
const anchor = document.createElement('a');
anchor.href = window.URL.createObjectURL(blob);
anchor.download = data
anchor.click();
},
error => {
console.log(error);
}
);
}
service.ts
getAccordo(filtro: Filter) {
return this.http.post<any>(
`${this.ENDPOINT}/export`,
filter,
{ responseType: 'blob' as 'json' }
)
}
响应头: