如何下载与readAllBytes一起发送angularjs的.xls文件

如何下载与readAllBytes一起发送angularjs的.xls文件,angularjs,download,restangular,Angularjs,Download,Restangular,我在后端应用程序中有一个喷射路径,它使用 FileUtils.readAllBytes(xlsFile) 在我的前端应用程序中,我使用angularjs和Restangular模块,所以我需要接收我的.xls文件并将其下载到用户的计算机上 我的密码里有 Restangular.one("localhost:9090/excel") .get() .then(function(response){ alert("Excel is here!"

我在后端应用程序中有一个喷射路径,它使用

FileUtils.readAllBytes(xlsFile)

在我的前端应用程序中,我使用angularjs和Restangular模块,所以我需要接收我的.xls文件并将其下载到用户的计算机上

我的密码里有

Restangular.one("localhost:9090/excel")
        .get()
        .then(function(response){
            alert("Excel is here!");
            var hiddenElement = document.createElement('a');
            hiddenElement.href = 'data:attachment/xls,' + encodeURIComponent(response);
            hiddenElement.download = 'reporte-anual.xls';
            hiddenElement.click();
        });
但它只会发出警报

我怎样才能做到这一点


谢谢大家

您不需要做所有这些,只需要在服务器上side@JoseM从我的后端我发送3个标题。。。访问控制允许源
(AllOrigins),
上次修改的
(DateTime(System.currentTimeMillis()),
内容处置`(“附件”,映射((“文件名”,文件名)))