downloading xlsx file in angular 2 with blob
<p>I want to download xlsx file from the client on angular 2 using rest api.</p>

<p>I'm getting a byte array as a response from my GET request and I'm sending it to download function with subscribe:</p>

<pre><code>let options = new RequestOptions({ search: params });
this.http.get(this.restUrl, options)
          .subscribe(this.download); 
</code></pre>

<p>download function using blob:</p>

<pre><code>download(res: Response) {
let data = new Blob([res.arrayBuffer()], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;' });
FileSaver.saveAs(data, this.fileName);};
</code></pre>

<p>my problem is that my file is corrupted all the time.
I tried a lot of versions of this but nothing works.</p>

<p>** also tried it with this solution and it doesn't works (the xlsx file is still corrupted)  -
<a href="https://stackoverflow.com/questions/38793859/angular-2-downloading-a-file">Angular 2 downloading a file: corrupt result</a> , the difference is that my data is an array Buffer and not string or json, and there is a difference between PDF and xlsx.</p>

<p>10x!</p>