title: Phpexcel display sheet(2) in html
body: <p>I have to display an excel workbook in html form because some will view the page with Macbooks and for sure not everybody has excel installed. The workbook has five sheets which have different number of columns and the column widths are different, so they cannot be put in one sheet. I'm using wamp server 2.4 with phpexcel 1.8, php 5.4.16, apache 2.4.4 under windows XP. I can get the different sheets active (show up first) by getActiveSheet(). But when I tried to display them in html, only the first sheet is shown. Seems it can't switch to other sheets. How can I get the html to show other sheets? Here is my code. I have modified it so it writes a workbook with 5 sheets with different background color in cell (A2); different column width in (B) and the actual sheet number in cell (A5). Thanks for your help in advance.</p>
  
  <pre><code>&lt;?php
  
  /** Error reporting */
  error_reporting(E_ALL);
  ini_set('display_errors', TRUE);
  ini_set('display_startup_errors', TRUE);
  date_default_timezone_set('Europe/London');
  
  if (PHP_SAPI == 'cli')
      die('This example should only be run from a Web Browser');
  
  /** Include PHPExcel */
  #require_once dirname(__FILE__) . '/../Classes/PHPExcel.php';
  require_once 'c:/wamp/www/Classes/PHPExcel.php';
  define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '&lt;br /&gt;');
  
  
  // Create new PHPExcel object
  $objPHPExcel = new PHPExcel();
  
  // Set document properties
  $objPHPExcel-&gt;getProperties()-&gt;setCreator("Maarten Balliauw")
                               -&gt;setLastModifiedBy("Maarten Balliauw")
                               -&gt;setTitle("Office 2007 XLSX Test Document")
                               -&gt;setSubject("Office 2007 XLSX Test Document")
                               -&gt;setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
                               -&gt;setKeywords("office 2007 openxml php")
                               -&gt;setCategory("Test result file");
  
  
  
  $fcolor=array("FF0000","00FF00","0000FF","FFF000","000FFF");
  
  $i=0;
  while ($i&lt;=4){
  echo 'sheet-&gt;'.$i, EOL;
  $objPHPExcel-&gt;createSheet();
  // Add some data
  $objPHPExcel-&gt;setActiveSheetIndex($i)
              -&gt;setcellValue('A1', 'Hello')
              -&gt;setCellValue('B2', 'world!')
              -&gt;setCellValue('C1', 'Hello')
              -&gt;setCellValue('D2', 'world!')
              -&gt;setCellValue('A4', 'Miscellaneous glyphs')
              -&gt;setCellValue('A5', 'Sheet='.$i);
  
  #$objPHPExcel-&gt;getActiveSheet()-&gt;getStyle('A2')-&gt;getFill()-&gt;getStartColor()-&gt;setRGB('FF0000');
  $objPHPExcel-&gt;getActiveSheet()-&gt;getStyle('A2')-&gt;applyFromArray(
                  array('fill' =&gt; array('type' =&gt; PHPExcel_Style_Fill::FILL_SOLID,'color' =&gt; array('rgb' =&gt; $fcolor[$i]))));
  $objPHPExcel-&gt;getActiveSheet()-&gt;getColumnDimension('B')-&gt;setWidth(5*($i+1));
  
  echo 'Index-&gt;'.$objPHPExcel-&gt;getActiveSheetIndex(),EOL;
  
  // Redirect output to a clientâ€™s web browser (Excel2007)
  header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  header('Cache-Control: max-age=0');
  $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'html');
  $objWriter-&gt;save('php://output');
  
  echo '&lt;br/&gt;';
  $i++;
  
  }
  
  echo 'Done',EOL;
  
  /**
  // Save Excel 2007 file
  echo date('H:i:s') . " Write to Excel2007 format\n";
  header('Content-type: application/vnd.ms-excel');
  header('Content-Disposition: attachment;filename="simple.xlsx"');
  header('Cache-Control: max-age=0');
  ob_end_clean();
  $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
  $objWriter-&gt;save('php://output');
  
  exit;
  **/
   ?&gt;
  </code></pre>