title: FileSaver.js with Angular 7
body: <p>I have a use case where I need to download data as an excel file. I am using Angular 7 (UI) and Java Spring REST API service. The REST API will generate the Excel file and send it to Angular where I use FileSaver.js module to save the file to disk. I see the blob being created and the size printed on the console, but the file does not save to disk.</p>
  
  <p>This used to work when I had Angular 4. Any help is greatly appreciated.</p>
  
  <p>Also, if anybody can suggest an alternative node module to achieve the same result, I am all ears.</p>
  
  <p>Below is the code snippet in Angular</p>
  
  <pre><code>this.myService.getDataAsXLSX(this.dataList).
      subscribe(byteArray =&gt; { 
              this.excelFileAsByteArray = byteArray; 
          }, error =&gt; console.log("There was an error."), 
          () =&gt; { 
              const blob = new Blob([this.excelFileAsByteArray.body], {type:'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; ; charset=UTF-8'}); 
              console.log('Blob size in filtered = ' + blob.size); 
          FileSaver.saveAs(blob, "MyData-" + this.datePipe.transform(this.currentDate, 'MM-dd-yyyy') + ".xlsx"); } ); 
  </code></pre>
  
  <p>Here is the code from the REST API</p>
  
  <pre><code>    ByteArrayOutputStream outputStream = new ExcelWriter().createExcelWorkbook(dataList, fullName); 
      byte[] byteArray = outputStream.toByteArray();
      HttpHeaders responseHeaders = new HttpHeaders();
  
  responseHeaders.set("Content-Type","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; ; charset=UTF-8");
  
  responseHeaders.set("Content-Disposition", "attachment;filename=MyData.xlsx"); responseHeaders.set("Expires", "0");
  
      return new ResponseEntity(byteArray, responseHeaders, HttpStatus.OK);
  </code></pre>