title: Export xlsx file using php
body: <p>I need to download a file in XLS &amp; XLSX format, I tried Many Way but it is not working.</p>
  
  <p>My download code is as follows:</p>
  
  <pre><code>$file = "Reports.xlsx";
  header('Content-Description: File Transfer');
  header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  header('Content-Disposition: attachment; filename='.basename($file));
  header('Content-Transfer-Encoding: binary');
  header('Expires: 0');
  header('Cache-Control: must-revalidate');
  header('Pragma: public');
  header('Content-Length: ' . filesize($file));
  readfile($file);
  </code></pre>
  
  <p>Both i Tried :</p>
  
  <pre><code>header('Content-type: application/octet-stream');  -  not working
  header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); -  not working
  </code></pre>
  
  <p>For Xls:</p>
  
  <pre><code>header("Content-Type: application/vnd.ms-excel; charset=UTF-8;");  - Working for Xls
  </code></pre>