title: PhpSpreadsheet corrupted xlsx file
body: <p>I have issue when trying to download xlsx file. It works just fine when i test it locally, but when i upload it to production server, file gets corrupted.</p>
  
  <p>this is the file output:
  <a href="https://i.stack.imgur.com/UsPhs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UsPhs.png" alt="enter image description here"></a>                 </p>
  
  <p>this is code im using:</p>
  
  <pre><code>&lt;?php
  
      require 'conn.php';
      require 'vendor/autoload.php';
  
      use PhpOffice\PhpSpreadsheet\Spreadsheet;
      use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
      use PhpOffice\PhpSpreadsheet\IOFactory;
  
  
      $spreadsheet = new Spreadsheet();
      $sheet = $spreadsheet-&gt;getActiveSheet();
      $sheet-&gt;setCellValue('A1', '#');
      $sheet-&gt;setCellValue('B1', 'First');
      $sheet-&gt;setCellValue('C1', 'Last');
      $sheet-&gt;setCellValue('D1', 'Handle');
  
      header('Content-Type: application/vnd.openxmlformats- 
      officedocument.spreadsheetml.sheet');
      header('Content-Disposition: attachment;filename="text.xlsx"');
      header('Cache-Control: max-age=0');
      $writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
      $writer-&gt;save('php://output');
      die;
  
  </code></pre>
  
  <p>i tried changing header to, it did not help:</p>
  
  <p>header('Content-type: application/vnd.ms-excel'); </p>