title: How to properly download excel file with Angular2
body: <p>This is the code of my service which makes post request with response an xls file :</p>
  
  <pre class="lang-js prettyprint-override"><code>exportInternalOrder(body) {
          let user_token: string = this.sessionService.getToken();
          let headers = new Headers();
          headers.append('responseType', 'arraybuffer');
          headers.append('Authorization', 'Bearer ' + user_token);
          return this.http.post(this.config.exportInternalOrder, body,{
              headers: headers
          }).map(res =&gt; new Blob([res._body],{ type: 'application/vnd.ms-excel' }));
      }
  </code></pre>
  
  <p>Which is supposed to handle response of excel file.
  This is the code invoking it:</p>
  
  <pre class="lang-js prettyprint-override"><code>let objToSend = this.makeObjToSend(false);
  this.reportingService.exportExcel(objToSend)
      .subscribe(
          data =&gt; {
              this.exportData(data);
          },
          error =&gt; {
              this.errorFilterMsg.push({ severity: 'error', detail: 'Report exporting has failed!' });
          }
  );
  </code></pre>
  
  <p>And this is the saving of the file (for some reason window.open does nothing):</p>
  
  <pre class="lang-js prettyprint-override"><code>exportData(data){       
          let blob = data;
          let a = document.createElement("a");
          a.href = URL.createObjectURL(blob);
          a.download = 'fileName.xls';
          document.body.appendChild(a);
          a.click();        
      }
  </code></pre>
  
  <p>But the file still saves as corrupted one. While using postman and curl it comes ok. Any help would be appreciated.</p>