title: code to expand excel column width in php while exporting
body: <p>I am new to PHP and trying to export some DB data to Excel file as below. But in the output I want the column widths to be adjusted automatically to view the entire content. See the code I am using to export data. I am not using any third party libraries for export.</p>
  
  <pre><code>&lt;?php    
  require_once("db.php");   
  
  $contents="email,time_in,v_id,time_out\n";   
  
  $user_query = mysql_query('SELECT  * FROM table');   
  
  while($row = mysql_fetch_array($user_query))
  {
  $contents.=$row['email'].",";
  $contents.=$row['time_in'].",";
  
  $contents.=$row['v_id'].",";
  $contents.=$row['time_out']."\n";
  }
  
  // remove html and php tags etc.
  $contents = strip_tags($contents); 
  
  //header to make force download the file
  
  header("Content-Disposition: attachment; filename=Report".date('d-m-Y').".xls");
  print $contents;
  
  
  ?&gt;
  </code></pre>
  
  <p>Is there any way to format the output ?</p>