这是我的情况:
Service.ts
excelGeneration(filters) {
var timestamp = new Date().getTime();
/* var options = this.setOptions();*/
let headers = new Headers();
headers.append('Accept', 'application/vnd.ms-excel');
let options = new RequestOptions({ headers: headers, body: "", responseType: ResponseContentType.Blob });
return this.http.post(AppSettings.BASEURL_LOCAL + 'esportacatalogo', filters, options).map(res => new Blob([res.blob()],{ type: 'application/vnd.ms-excel' }))
.catch((error: any) => {
this.handleError(error);
return observableThrowError(error.statusText);
}).finally(() => {
this.hideLoader();
});
}
Component.ts
generaExcel(){
let self = this;
let filters = {};
self.pageService.excelGeneration(filters).toPromise().then(response => {
const url= window.URL.createObjectURL(response);
window.open(url);
});
}
我期望Back End能够提供类似“ Hello World”之类的消息。 Atm我正在下载带有此消息“响应状态代码200 OK”的Excel。
我错了哪里?谢谢