After sending a request to the server and receiving a response, I am struggling with converting this response into an Excel file.
Response header:
Connection →keep-alive
cache-control →no-cache, no-store, max-age=0, must-revalidate
content-disposition →attachment; filename=demo.xls
content-length →7680
content-type →application/vnd.ms-excel
date →Wed, 19 Sep 2018 14:40:47 GMT
expires →0
pragma →no-cache
server →Apache
x-content-type-options →nosniff
x-frame-options →DENY
x-xss-protection →1; mode=block
Response data:
ࡱ; RootEntryWorkbook A\pmidadm Ba==h:#8X@"1Arial1Arial1Arial1Arial1Calibri1Calibri1Calibri"$"#,##0_);("$"#,##0)"$"#,##0_);Red "$"#,##0.00_);(* "-"??);(@) #.##0 #,##0.000[$-1009]mmmm d, yyyy;@_($*
,##0.00_)
+ ) , * ! " # # ! # # `Demo
Here is what I tried:
var blob = new Blob([result.data],
{
'type': 'application/vnd.ms-excel',
}
)
var link = document.createElement('a');
link.href = window.URL.createObjectURL(blob);
link.download = 'demo.xls';
document.body.appendChild(link);
link.click();
Unfortunately, when attempting to open the file, I encountered an error and it failed to open correctly.
Any assistance or guidance would be greatly appreciated. Thank you.