2015-05-07 79 views
0

我试图从服务器上下载一个excel文件在angularjs中,但是当我尝试生成一个blob时,我收到了一些罕见的字符。AngularJs下载excel

这是我的服务器响应(字节数组):

[-48,-49,17,-32,-95,-79,26,-31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,59,0,3,0,-2,-1,9,0,6,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,7,0,0,0,1,0,0,0,-2,-1,-1,-1,0,0,0,0,8,0,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1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,0,0,0,0,0,0,0,0,0,0,0,0,0,47,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9,8,16,0,0,6,5,0,-45,16,-52,7,65,0,0,0,6,0,0,0,-31,0,2,0,-80,4,-63,0,2,0,0,0,-30,0,0,0,92,0,112,0,7,0,0,114,111,100,114,105,103,111,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,66,0,2,0,-80,4,97,1,2,0,0,0,61,1,2,0,0,0,-100,0,2,0,14,0,25,0,2,0,0,0,18,0,2,0,0,0,19,0,2,0,0,0,-81,1,2,0,0,0,-68,1,2,0,0,0,61,0,18,0,104,1,14,1,92,58,-66,35,56,0,0,0,0,0,1,0,88,2,64,0,2,0,0,0,-115,0,2,0,0,0,34,0,2,0,0,0,14,0,2,0,1,0,-73,1,2,0,0,0,-38,0,2,0,0,0,49,0,21,0,-56,0,0,0,-1,127,-112,1,0,0,0,0,0,0,5,0,65,114,105,97,108,49,0,21,0,-56,0,0,0,-1,127,-112,1,0,0,0,0,0,0,5,0,65,114,105,97,108,49,0,21,0,-56,0,0,0,-1,127,-112,1,0,0,0,0,0,0,5,0,65,114,105,97,108,49,0,21,0,-56,0,0,0,-1,127,-112,1,0,0,0,0,0,0,5,0,65,114,105,97,108,30,4,26,0,5,0,21,0,0,34,36,34,35,44,35,35,48,95,41,59,40,34,36,34,35,44,35,35,48,41,30,4,31,0,6,0,26,0,0,34,36,34,35,44,35,35,48,95,41,59,91,82,101,100,93,40,34,36,34,35,44,35,35,48,41,30,4,32,0,7,0,27,0,0,34,36,34,35,44,35,35,48,46,48,48,95,41,59,40,34,36,34,35,44,35,35,48,46,48,48,41,30,4,37,0,8,0,32,0,0,34,36,34,35,44,35,35,48,46,48,48,95,41,59,91,82,101,100,93,40,34,36,34,35,44,35,35,48,46,48,48,41,30,4,44,0,42,0,39,0,0,95,40,42,32,35,44,35,35,48,95,41,59,95,40,42,32,40,35,44,35,35,48,41,59,95,40,42,32,34,45,34,95,41,59,95,40,64,95,41,30,4,53,0,41,0,48,0,0,95,40,34,36,34,42,32,35,44,35,35,48,95,41,59,95,40,34,36,34,42,32,40,35,44,35,35,48,41,59,95,40,34,36,34,42,32,34,45,34,95,41,59,95,40,64,95,41,30,4,61,0,44,0,56,0,0,95,40,34,36,34,42,32,35,44,35,35,48,46,48,48,95,41,59,95,40,34,36,34,42,32,40,35,44,35,35,48,46,48,48,41,59,95,40,34,36,34,42,32,34,45,34,63,63,95,41,59,95,40,64,95,41,30,4,52,0,43,0,47,0,0,95,40,42,32,35,44,35,35,48,46,48,48,95,41,59,95,40,42,32,40,35,44,35,35,48,46,48,48,41,59,95,40,42,32,34,45,34,63,63,95,41,59,95,40,64,95,41,-32,0,20,0,0,0,0,0,-11,-1,32,0,0,0,0,0,0,0,0,0,0,0,-64,32,-32,0,20,0,1,0,0,0,-11,-1,32,0,0,-12,0,0,0,0,0,0,0,0,-64,32,-32,0,20,0,1,0,0,0,-11,-1,32,0,0,-12,0,0,0,0,0,0,0,0,-64,32,-32,0,20,0,2,0,0,0,-11,-1,32,0,0,-12,0,0,0,0,0,0,0,0,-64,32,-32,0,20,0,2,0,0,0,-11,-1,32,0,0,-12,0,0,0,0,0,0,0,0,-64,32,-32,0,20,0,0,0,0,0,-11,-1,32,0,0,-12,0,0,0,0,0,0,0,0,-64,32,-32,0,20,0,0,0,0,0,-11,-1,32,0,0,-12,0,0,0,0,0,0,0,0,-64,32,-32,0,20,0,0,0,0,0,-11,-1,32,0,0,-12,0,0,0,0,0,0,0,0,-64,32,-32,0,20,0,0,0,0,0,-11,-1,32,0,0,-12,0,0,0,0,0,0,0,0,-64,32,-32,0,20,0,0,0,0,0,-11,-1,32,0,0,-12,0,0,0,0,0,0,0,0,-64,32,-32,0,20,0,0,0,0,0,-11,-1,32,0,0,-12,0,0,0,0,0,0,0,0,-64,32,-32,0,20,0,0,0,0,0,-11,-1,32,0,0,-12,0,0,0,0,0,0,0,0,-64,32,-32,0,20,0,0,0,0,0,-11,-1,32,0,0,-12,0,0,0,0,0,0,0,0,-64,32,-32,0,20,0,0,0,0,0,-11,-1,32,0,0,-12,0,0,0,0,0,0,0,0,-64,32,-32,0,20,0,0,0,0,0,-11,-1,32,0,0,-12,0,0,0,0,0,0,0,0,-64,32,-32,0,20,0,0,0,0,0,1,0,32,0,0,0,0,0,0,0,0,0,0,0,-64,32,-32,0,20,0,1,0,43,0,-11,-1,32,0,0,-8,0,0,0,0,0,0,0,0,-64,32,-32,0,20,0,1,0,41,0,-11,-1,32,0,0,-8,0,0,0,0,0,0,0,0,-64,32,-32,0,20,0,1,0,44,0,-11,-1,32,0,0,-8,0,0,0,0,0,0,0,0,-64,32,-32,0,20,0,1,0,42,0,-11,-1,32,0,0,-8,0,0,0,0,0,0,0,0,-64,32,-32,0,20,0,1,0,9,0,-11,-1,32,0,0,-8,0,0,0,0,0,0,0,0,-64,32,-109,2,4,0,16,-128,3,-1,-109,2,4,0,17,-128,6,-1,-109,2,4,0,18,-128,4,-1,-109,2,4,0,19,-128,7,-1,-109,2,4,0,0,-128,0,-1,-109,2,4,0,20,-128,5,-1,96,1,2,0,0,0,-123,0,39,0,30,7,0,0,0,0,31,0,99,117,101,115,116,105,111,110,97,114,105,111,95,53,53,52,57,56,99,97,99,48,48,97,51,100,101,98,48,100,102,-116,0,4,0,1,0,1,0,-82,1,4,0,1,0,1,4,23,0,8,0,1,0,0,0,0,0,0,0,-4,0,-105,1,34,0,0,0,34,0,0,0,15,0,0,78,111,109,98,114,101,32,112,97,99,105,101,110,116,101,26,0,0,84,46,32,105,100,101,110,116,105,102,105,99,97,99,105,-13,110,32,112,97,99,105,101,110,116,101,6,0,0,73,80,83,83,45,52,6,0,0,73,80,83,83,45,49,12,0,0,67,117,101,115,116,105,111,110,97,114,105,111,6,0,0,73,80,83,83,45,51,6,0,0,73,80,83,83,45,50,23,0,0,73,100,101,110,116,105,102,105,99,97,99,105,-13,110,32,112,97,99,105,101,110,116,101,6,0,0,73,80,83,83,45,56,2,0,0,73,68,6,0,0,78,-6,109,101,114,111,28,0,0,73,80,83,83,95,85,82,73,78,65,82,89,95,81,85,65,76,73,84,89,95,79,70,95,76,73,70,69,10,0,0,73,80,83,83,95,83,67,79,82,69,17,0,0,70,101,99,104,97,32,100,101,32,115,111,108,117,99,105,-13,110,6,0,0,73,80,83,83,45,54,6,0,0,73,80,83,83,45,55,6,0,0,73,80,83,83,45,53,1,0,0,53,24,0,0,53,53,52,57,56,99,97,99,48,48,97,51,100,101,98,48,100,102,100,98,50,100,98,57,1,0,0,54,2,0,0,49,48,1,0,0,48,4,0,0,73,80,83,83,12,0,0,79,99,99,97,115,105,111,110,97,108,108,121,5,0,0,49,50,49,50,50,1,0,0,49,12,0,0,49,32,116,111,32,54,32,116,105,109,101,115,1,0,0,50,11,0,0,51,32,77,97,121,44,32,50,48,49,53,1,0,0,56,16,0,0,77,111,115,116,32,111,102,32,116,104,101,32,116,105,109,101,3,0,0,79,110,101,14,0,0,114,111,100,114,105,103,111,32,99,97,114,100,105,111,1,0,0,55,-1,0,42,0,8,0,93,5,0,0,12,0,0,0,-39,5,0,0,-120,0,0,0,66,6,0,0,-15,0,0,0,-115,6,0,0,60,1,0,0,-41,6,0,0,-122,1,0,0,10,0,0,0,9,8,16,0,0,6,16,0,-69,13,-52,7,-63,0,0,0,6,0,0,0,11,2,20,0,0,0,0,0,1,0,0,0,3,0,0,0,0,0,0,0,-10,9,0,0,13,0,2,0,1,0,12,0,2,0,100,0,15,0,2,0,1,0,17,0,2,0,0,0,16,0,8,0,-4,-87,-15,-46,77,98,80,63,95,0,2,0,1,0,42,0,2,0,0,0,43,0,2,0,0,0,-126,0,2,0,1,0,-128,0,8,0,0,0,0,0,0,0,0,0,37,2,4,0,0,0,-1,0,-127,0,2,0,-63,4,20,0,0,0,21,0,0,0,-125,0,2,0,0,0,-124,0,2,0,0,0,-95,0,34,0,1,0,100,0,1,0,1,0,1,0,2,0,44,1,44,1,0,0,0,0,0,0,-32,63,0,0,0,0,0,0,-32,63,1,0,85,0,2,0,8,0,0,2,14,0,0,0,0,0,3,0,0,0,0,0,17,0,0,0,8,2,16,0,1,0,0,0,17,0,-1,0,0,0,0,0,64,1,15,0,8,2,16,0,2,0,0,0,17,0,-1,0,0,0,0,0,64,1,15,0,-3,0,10,0,1,0,0,0,15,0,10,0,0,0,-3,0,10,0,1,0,1,0,15,0,9,0,0,0,-3,0,10,0,1,0,2,0,15,0,4,0,0,0,-3,0,10,0,1,0,3,0,15,0,13,0,0,0,-3,0,10,0,1,0,4,0,15,0,1,0,0,0,-3,0,10,0,1,0,5,0,15,0,7,0,0,0,-3,0,10,0,1,0,6,0,15,0,0,0,0,0,-3,0,10,0,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,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1] 

及其标头:

Access-Control-Allow-Headers → Content-Type, jwt 
Access-Control-Allow-Methods → POST, GET, PUT, DELETE 
Access-Control-Allow-Origin → * 
Content-Disposition → attachment; filename=questionnaire_55498cac00a3deb0dfdb2db9.xls 
Content-Length → 13723 
Content-Type → application/vnd.ms-excel; charset=UTF-8 
Date → Thu, 07 May 2015 08:40:48 GMT 
Last-Modified → Thu, 07 May 2015 08:40:48 GMT 
Server → spray-can/1.3.2 

以我angularjs应用我有类似:

// HttpService 
downloadRequest: function (url, handledStatuses) { 
    var hs = handledStatuses || []; 
    var deferred = $q.defer(); 
    $http.get(url, {responseType: 'arraybuffer', handledStatuses: hs}) 
     .success(function (data, status, headers, config) { 
     deferred.resolve(data); 
     }) 
     .error(function (error, status, headers, config) { 
     deferred.reject(error); 
     }); 
    return deferred.promise; 
    } 

// Download Service 
getQuestionnaireReport: function (questionnaireId) { 
    return HttpManager.downloadRequest(UrlManager.getReportsUrl() + 'questionnaires/' + questionnaireId); 
    } 

// Download manager 
downloadFile: function (bytes, name, extension, type) { 
    if (this.detectIE() === false) { 
    var urlCreator = window.URL || window.webkitURL || window.mozURL || window.msURL; 
    var link = document.createElement("a"); 
    if ("download" in link) { 
     var blob = new Blob([bytes], {type: type}); 
     var url = urlCreator.createObjectURL(blob); 
     link.setAttribute("href", url); 
     link.setAttribute("download", name + '.' + extension); 

     var event = document.createEvent('MouseEvents'); 
     event.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null); 
     link.dispatchEvent(event); 
    } 
    } 
    else { 
    window.navigator.msSaveOrOpenBlob(new Blob([bytes], {type: type}), name + '.' + extension); 
    } 
}, 

// In my controller 
$scope.downloadQuestionnaireReport = function (questionnaireId) { 
    $scope.downloadPr = DoctorServices.getQuestionnaireReport(questionnaireId); 
    $scope.downloadPr.then(
    function (response) { 
     DownloadsManager.downloadFile(response, 'questionnaire_' + questionnaireId, 'xls', 'application/octet-stream'); 
    } 
); 
    return $scope.downloadPr; 
}; 

我已经尝试过不同类型的内容类型和responseTypes,我的问题是我越来越离奇了人物当我尝试打开下载的文件,像这样:

When I try to open generated file

When I open generated file

我缺少的东西?

非常感谢您提前。

+0

你说你的回应是一个字节数组,但你显示的是JSON – Musa

+0

是的,你是对的,我的服务器响应是不正确的。我刚刚回答了我自己的问题。希望它能帮助别人。问候! –

回答

0

经过几个小时寻找解决这个问题,我意识到我的问题是在我使用的响应编组器。

目前我使用spray.io作为我的休息服务提供者和我的json响应,我使用的是Json4s库。在这个问题中,我的服务器响应不正确,所以我找到的解决方案是为这个特定的服务删除Json4s编组器;然后所有的都按预期工作。