title: Download excel file in javascript from Rest API response content-disposition outputs [Object, Object]
body: <p>I want to download a excel file from my angularJs code. Where i made a http post request to Java Rest API and returned the file with header 
  "Content-Disposition" : "attachment; filename=\"new_excel_file.xlsx\""</p>
  
  <p>Java Code</p>
  
  <pre><code>@Post 
  @Path("/excel/trekResult")
  @Produces("application/vnd.ms-excel")
  public Response getResultsReport(@HeaderParam(Constants.ID) Long userId, @QueryParam(Constants.COMPANY_TREK_ID) Integer companyTrekId) {
  String CONTENT_DESPOSITION = "Content-Disposition";
  String CONTENT_ATTACHEMENT = "attachment; filename=\"new_excel_file.xlsx\"";
  
  //Generates a excel file in local file system
  File excelFile = misHelper.writeToFile(workBook, mis, userId, "trek-results");
  
  return Response.ok().entity((Object)excelFile).
      header(CONTENT_DESPOSITION, CONTENT_ATTACHEMENT).build();
  
  }
  </code></pre>
  
  <p>On Javascript Side</p>
  
  <pre><code>myService.exportResult($scope.companyTrek.id).then(function(result) {
    if(result !== undefined || result !== '') {
      var blob = new Blob([result], {
        type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
      });
      var objectUrl = URL.createObjectURL(blob);
      saveAs(blob, 'Trek-Results-'+fetchCurrentDate()+ '.xlsx');
    }
  }
  </code></pre>
  
  <p>Used FileSaver.js to save file. </p>
  
  <p><strong>The output file is [Object, Object]</strong></p>
  
  <p><strong>Tested The locally generated file.</strong></p>
  
  <p>Here is a similar question for reference that didn't help me.</p>
  
  <p><a href="https://stackoverflow.com/questions/21867120/receive-an-excel-file-as-response-in-javascript-from-a-rest-service">receive an excel file as response in javascript from a Rest service</a></p>