title: PHPExcel how to apply alignment for the whole document created from mysql table
body: <p>I used <code>PHPExcel</code> library to generate excel files based on the table created by the mysql query. I created multiple tabs with individual data from different queries. </p>
  
  <p>I need to align the data in the all the cells in all the tabs (worksheets) to center.</p>
  
  <p><strong>This is my code:</strong></p>
  
  <pre><code>$mysql_xls = new MySqlExcelBuilder($mysql_db,$mysql_user,$mysql_pass);
  
  // Add the SQL statements to the spread sheet
  
  $tab_name = "tabname";
  $mysql_xls-&gt;add_page($tab_name,$sql_statement,NULL,'A',1);
  
  $phpExcel = $mysql_xls-&gt;getExcel();
  
  $phpExcel-&gt;setActiveSheetIndex(0); // Set the sheet to the first page (default first page).
  </code></pre>
  
  <p>I tried the following to align the text in the cells but no change:</p>
  
  <pre><code>$phpExcel-&gt;getActiveSheet(0)-&gt;getStyle()-&gt;getAlignment()-&gt;setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  </code></pre>