Отправить ответ Exel от JAX-RS на AngularJS - PullRequest
0 голосов
/ 11 декабря 2018

Я пытаюсь сгенерировать Exel, используя apache-poi в моей службе JAX-RS, и отправляю ответ application / vnd.ms-excel на приложение angularJs.файл успешно загружен, но данные внутри него закодированыполучаю ответ ниже

<data contentType="application/vnd.ms-excel" contentLength="3368">UEsDBBQACAgIAJVbi00AAAAAAAAAAAAAAAALAAAAX3JlbHMvLnJlbHOtksFqwzAMhl/F6N447WCMUbeXMuhtjO4BNFtJTGLL2NqWvf3MLltLChvsKCR9/wfSdj+HSb1RLp6jP3XTgqJo2fnYG3g+PazuQBXB6HDiSAYiw363faIJpW6UwaeiKiIWA4NIute62D8CloYTxdrpOAeUWuZeJ7Qj9qQ3bXur808GnDPV0RnIR7cGdcLckxiYJ/3OeXxhHpuKrT8/RL8J5a7zlg5sXwNFWci+mAC97LL5dnFsHzPXTUzpv2VoFoqO3CrVBMriqVwzulkwspzpb0rXP6IDCToU/KJeCOmzH9h9AlBLBwinjHq94wAAAEkCAABQSwMEFAAICAgAlVuLTQAAAAAAAAAAAAAAABMAAABbQ29udGVudF9UeXBlc10ueG1stVPLbsIwEPyVyNcqNvRQVRU/Qx/HFqn0A1x7k1j4Ja+h8PddBziUUokKcfJjZmdmV/ZktnG2WkNCE3zDxnzEKvAqaOO7hn0sXup7VmGWXksbPDTMBzabThbbCFhRqceG9TnHByFQ9eAk8hDBE9KG5GSmY+pElGopOxC3o9E/UMFn8LnORYNNJ0/QypXN1ePuvkg3TMZoP5KZUom110ei9V4/J7ADB3sT8YYIrHreP8quG0KRiTMcjgvLmereaC7JaPhXtNC2Rj8OauWohENR1aDrmIiYsj99zrlM+VU6EhREnhOKgqT5Jd6Hsag/4CzDQrzI8ahbjAmkxh4gO8uxlwn0e070mH6H2Fjxg3DFHHlrT0yhBBg/a06AVu6k8afcv0JafoawvJ5/cRj2f9kPIIphGR9yiOF7T78BUEsHCHqUynE7AQAAHAQAAFBLAwQUAAgICACVW4tNAAAAAAAAAA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AAAAfAUAAHhsL3N0eWxlcy54bWxQSwECFAAUAAgICACVW4tNeD+yMtoAAABeAQAADwAAAAAAAAAAAAAAAAD8BgAAeGwvd29ya2Jvb2sueG1sUEsBAhQAFAAICAgAlVuLTYYDO5HUAAAAMwIAABoAAAAAAAAAAAAAAAAAEwgAAHhsL19yZWxzL3dvcmtib29rLnhtbC5yZWxzUEsBAhQAFAAICAgAlVuLTSBhHCVeAQAA4QIAABgAAAAAAAAAAAAAAAAALwkAAHhsL3dvcmtzaGVldHMvc2hlZXQxLnhtbFBLBQYAAAAACQAJAD8CAADTCgAAAAA=</data>

1 Ответ

0 голосов
/ 11 декабря 2018

Вы можете попробовать это? ..

      $scope.downloadExcel = function() {
            exelService.getExcel({}).then(function(data) {
            var data = window.atob(data);
                var buf = new ArrayBuffer(data.length * 2);
                var bufView = new Uint8Array(buf);
                var file;

                for (var i = 0, strLen = data.length; i < strLen; i++) {
                    bufView[i] = data.charCodeAt(i);
                }

                file = new Blob([buf], { type: 'application/vnd.ms-excel' });
                this.fileURL = URL.createObjectURL(file);
                window.open(this.fileURL);
           })
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...