Hi I recently started working on angular and I have a requirement to create and download excel file using asp.net web api and angular 8
I created excel file using Asp.net Web API and returning file as
return File(excelPackage.GetAsByteArray(), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "test.xlsx");
I have to read this excel file using angular and download
GetExportExcel(editQuoteFilters: EditQuoteModel):Observable<any>{
let postHeaders = new HttpHeaders();
postHeaders.append('Content-Type', 'application/json');
postHeaders.append('responseType', 'blob');
return this.http.post<any>(this.ExcelExportLevel0ApiUrl, editQuoteFilters,{ headers: postHeaders,
responseType : 'arraybuffer' as 'json'})
.pipe(map((res) =>{
var blob = new Blob([res.blob()], {type: "application/vnd.ms-excel"})
return blob
})
);
}