title: Download xls file angular jax-rs
body: <p>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:</p>
  
  <pre><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();
  }
  </code></pre>
  
  <p>And i have the following angular code in order to receive the file sended from the server side:</p>
  
  <p>My html code:   </p>
  
  <pre><code>&lt;a href ng-click="actionTsunamiXls()" style="font-size: 80%;"&gt;
  &lt;img style="max-width:15px;" src="/img/csv.jpg"/&gt;Tsunami Xls
  &lt;/a&gt;
  </code></pre>
  
  <p>My controller:</p>
  
  <pre><code>$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);
   });
  </code></pre>
  
  <p>};</p>
  
  <p>And My service code:</p>
  
  <p>.....</p>
  
  <pre><code>service.getTsunamiXls = function (callback) {
   $http.get(url + ':' + port + '/' + context + '/rest-ws/team/exportemployeexls')
   .success(function (response) {
   callback(response);
   });
  </code></pre>
  
  <p>The problem is when i click on button in order to dowload the xls file i get an xls file not well formated.</p>
  
  <p>The response varibale has a wrong value like this :</p>
  
  <p>��ࡱ���ࡱ���ࡱ���ࡱ���ࡱ���ࡱ���ࡱ���ࡱ���ࡱ���ࡱ�`""@ @ ......</p>
  
  <p>Note that when i use the url "<a href="http://localhost:8090/myapp/rest-ws/team/exportemployeexls" rel="nofollow">http://localhost:8090/myapp/rest-ws/team/exportemployeexls</a>" directely in the browser i get a well formated xls.</p>
  
  <p>Anyone  have an idea in how to solde this roblem and to dowload an xls file using angular and jax-rs ??
       };</p>