title: How to create xlsx file without using any excel library PHP
body: <p>This is right now I am using.</p>
  
  <pre><code>$mimeType = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
  header('Content-Description: File Transfer');
  header('Content-Type: ' . $mimeType);
  header('Content-Disposition: attachment; filename='.basename($type.'.xlsx'));
  header('Content-Transfer-Encoding: binary');
  header('Expires: 0');   
  header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  header('Pragma: public');
  print "$header\n$data";
  exit;
  </code></pre>
  
  <p><code>$header</code> variable contains the header row of excel to be generated and looks like this </p>
  
  <p><code>$header= "Business_Name\tBusiness_Type\tType";</code></p>
  
  <p>separated by <code>\t</code></p>
  
  <p>and <code>$data</code> contains rows to be generated under header columns. They are also separated by <code>\t</code> and a row is terminated by <code>\n</code>.</p>
  
  <p>With the current setup file is downloaded but it is not opening with ms excel and showing this message.</p>
  
  <blockquote>
    <p>Excel cannot open the file "file name"
    because the file format or file
    extension is not valid. Verify that
    the file format has not been corrupted
    and that the file extension matches
    the format of the file.</p>
  </blockquote>
  
  <p>What header should be sent to server? or how do I generate that file?</p>