title: Angular2 Download Excel File from Asp.Net Core Corrupted
body: <p>So I am using ASP.Net Core as the backend and Angular as my front end. I am trying to download a an excel file created in a controller: </p>
  
  <pre><code>  public IActionResult DownloadServerList()
      {
          byte[] fileContents;
  
          string fileName = @"servers.xlsx";
  
          if (System.IO.File.Exists(Path.Combine(@"C:\Users\EC64473\source\repos\ServerInventoryCore", fileName)))
              System.IO.File.Delete(Path.Combine(@"C:\Users\EC64473\source\repos\ServerInventoryCore", fileName));
  
          FileInfo file = new FileInfo(Path.Combine(@"C:\Users\EC64473\source\repos\ServerInventoryCore", fileName));
  
          using (ExcelPackage package = new ExcelPackage(file))
          {
              List&lt;Server&gt; serverList = context.Servers.ToList();
  
              ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("Servers");
              int totalRows = serverList.Count();
  
              worksheet.Cells[1, 1].Value = "Server ID";
              worksheet.Cells[1, 2].Value = "Server Name";
              worksheet.Cells[1, 3].Value = "Exists";
              worksheet.Cells[1, 4].Value = "UUID";
              int i = 0;
              for (int row = 2; row &lt;= totalRows + 1; row++)
              {
                  worksheet.Cells[row, 1].Value = serverList[i].ID;
                  worksheet.Cells[row, 2].Value = serverList[i].ServerName;
                  worksheet.Cells[row, 3].Value = serverList[i].ServerExists;
                  worksheet.Cells[row, 4].Value = serverList[i].ServerUUID;
                  i++;
              }
              package.Save();
  
              fileContents = package.GetAsByteArray();
          }
  
          //if (fileContents == null || fileContents.Length == 0)
          //    return NotFound();
  
          return File(
              fileContents: fileContents,
              contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
              fileDownloadName: "servers.xlsx"
              );
      }
  </code></pre>
  
  <p>I can verify the excel file created is not corrupt while sending it as a file and the total size is: around 96 kb. </p>
  
  <p>My Service is: </p>
  
  <pre><code> getServerListAsExcel(): Observable&lt;any&gt; {
  return this.http.get('Servers/DownloadServerList', { responseType: ResponseContentType.Blob  });
  </code></pre>
  
  <p>}</p>
  
  <p>My Component.ts is: </p>
  
  <pre><code> buttonPress() {
  this.serverService.getServerListAsExcel()
    .subscribe(data =&gt; {
      console.log(data);
      saveAs(data._body, 'test.xlsx');
    });
  </code></pre>
  
  <p>When log the data the result is: </p>
  
  <pre><code>Response {_body: Blob(195104), status: 200, ok: true, statusText: "OK", 
  headers: Headers, …}
  headers: Headers
  _headers: Map(8) {"date" =&gt; Array(1), "server" =&gt; Array(1), "x-powered-by" =&gt; 
  Array(1), "content-type" =&gt; Array(1), "status" =&gt; Array(1), …}
  _normalizedNames: Map(8) {"date" =&gt; "date", "server" =&gt; "server", "x-powered- 
  by" =&gt; "x-powered-by", "content-type" =&gt; "content-type", "status" =&gt; "status", …}
  __proto__: Object
  ok: true
  status: 200
  statusText: "OK"
  type: 2
  url: "https://localhost:44312/Servers/DownloadServerList"
  _body: Blob(195104)
  size: 195104
  type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
  </code></pre>
  
  <p>The file downloads, however is twice the size of the original i saved locally on my system when creating the file ion the controller. I noticed the size seemed to double on the "getAsByteArray" function of ExcelPackage. the message that comes up when trying to open is "We found a problem with some of the content in '.....xlsx'.Do you want to recover?" at which point I click yes and Excel hangs. Is there anyone who can point me in the right direction? </p>