title: how to export xlsx from mysql with php xlsxwriter
body: <p>I use <a href="https://github.com/mk-j/PHP_XLSXWriter" rel="nofollow noreferrer">PHP_XLSXWriter</a> class to export xlsx from mysql</p>
  
  <pre><code>include_once('xlsxwriter.class.php');
  $filename = "example.xlsx";
  header('Content-disposition: attachment; filename="'.XLSXWriter::sanitize_filename($filename).'"');
  header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
  header('Content-Transfer-Encoding: binary');
  header('Cache-Control: must-revalidate');
  header('Pragma: public');   
  $query="my query here";
  $result = mysql_query($query); 
  $rows = mysql_fetch_assoc($result); 
  $header = array(
    'ID'=&gt;'integer',
    'Subject'=&gt;'string',
    'Content'=&gt;'string',
  );
  $writer = new XLSXWriter();
  $writer-&gt;writeSheetHeader('Sheet1', $header);
  foreach($rows as $row)
      $writer-&gt;writeSheetRow('Sheet1', $row);
  //$writer-&gt;writeSheet($rows,'Sheet1', $header);//or write the whole sheet in 1 call 
  $writer-&gt;writeToStdOut();
  //$writer-&gt;writeToFile('example.xlsx');
  //echo $writer-&gt;writeToString();
  exit(0);
  </code></pre>
  
  <p>the export xlsx only has header, no data, what's the problem of my code?</p>