I am getting the file content as binary or byte array(FROM THE REST API) and want to convert this into a excel file and download it in client side using angular.js , but don't know how to do it. Can anyone help me out here.
Also im attaching the code here , .xls file is getting downloaded but after opening it file content remains same binary/byte content that im getting from a api response , instead of the actual file content. Can anyone tell what i am missing here. Or how i can convert/read the response to actual format. Any help is much appreciated as im completely stuck.
$http.get(__env.apiUrl+"/UserSurvey/GetTrackingReport?surveyId="+$rootScope.surveysummaryID,{headers:{"Content-type":"application/json",'sessionID':$rootScope.token}}).then(function(response){
console.log(response);
var blob = new Blob([response.data], {type: 'application/vnd.ms-excel'});
if (window.navigator && window.navigator.msSaveBlob) {
window.navigator.msSaveBlob(blob);
}
else {
var objectUrl = URL.createObjectURL(blob);
window.open(objectUrl);
}
},function(error){
console.log(error);
});
Many Thanks,