1
MVCパートは、MVCコントローラからExcelファイルを返すと、POSTリクエストでangularJS
リターンファイル(ストリーム、 "アプリケーション/ vnd.ms-エクセル"、file.FileName)からダウンロードしてください。
私は上記の方法でMVCコントローラからファイルを返しています。
AngularJSコントローラ
$scope.ExcelValidate = function() {
if ($scope.files && $scope.files.length && $scope.selectedFileType != -1) {
busyIndicatorService.showBusy("Uploading data...");
for (var i = 0; i < $scope.files.length; i++) {
var file = $scope.files[i];
$scope.file = file.name;
Upload.upload({
url: '/MasterExcelImport/ValidateExcelData',
fields: {
uploadType: $scope.selectedFileType.Key.Key
},
file: file
}).progress(function (evt) {
console.log('percent: ' + parseInt(100.0 * evt.loaded/evt.total));
$scope.file.progress = parseInt(100.0 * evt.loaded/evt.total);
}).success(function (data) {
busyIndicatorService.stopBusy();
var blob = new Blob([data], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" });
var objectUrl = URL.createObjectURL(blob);
window.open(objectUrl);
}).error(function (data, status, headers, config) {
busyIndicatorService.stopBusy();
});
}
}
};
戻るファイルが既に成功セクションに来ます。しかし、ダウンロード部分が失敗しました。
この問題を解決するのにお手伝いできますか?
おかげで、 Erandika Sandaruwan
はHTTP呼び出し –
は何のエラーメッセージの結果として、base64文字列を取得している角度Contoller方法あなたは? – georgeawg