Hi all,
I use jax-ws in the server side and angularjs in the client side.
I'm trying to download an xls file send from server side.
In the server side i use this code:
@GET
@Path("/exportemployeexls")
@Produces("application/vnd.ms-excel")
@PermitAll
public Response exportAllEmployeeOnXLSFile(){
.......
File employeeFile = new File("C://employee.xls");
ResponseBuilder response = Response.ok((Object) employeeFile);
response.header("Content-Disposition",
"attachment; filename=employeeFile.xls");
return response.build();}
And i have the following angular code in order to receive the file sended
from the server side:
My html code:
<a href ng-click="actionTsunamiXls()" style="font-size: 80%;">
<img style="max-width:15px;" src="/img/csv.jpg"/>Tsunami Xls
</a>
My controller:
$scope.actionTsunamiXls = function () {
console.info("Export XLS");
NavService.getTsunamiXls(function (response) {
$timeout(function () {
var hiddenElement = document.createElement('a');
hiddenElement.href = 'data:attachment/xls,' + encodeURIComponent
(response);
hiddenElement.download = 'result.xls';
hiddenElement.click();
}, 200);
});
};
And My service code:
.....
service.getTsunamiXls = function (callback) {
$http.get(url + ':' + port + '/' + context + '/rest-ws/team/
exportemployeexls')
.success(function (response) {
callback(response);
});
};
The problem is when i click on button in order to dowload the xls file i
get an xls file not well formated.
The response varibale has a wrong value like this :
�� ࡱ ��� ࡱ ��� ࡱ ��� ࡱ ��� ࡱ ��� ࡱ ��� ࡱ ��� ࡱ ��� ࡱ ��� ࡱ �`""@ @ ......
*Note that when i use the url
"http://localhost:8090/myapp/rest-ws/team/exportemployeexls" directely in
the browser i get a well formated xls.*
Anyone have an idea in how to solde this roblem and to dowload an xls file
using angular and jax-rs ??
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.