title: PHPExcel - creating multiple sheets by iteration
body: <p>I'm trying to create multiple sheets by iteration in phpexcel:</p>
  
  <pre><code>$i=0;
  
  while ($i &lt; 10) {
  
  // Add new sheet
  $objWorkSheet = $objPHPExcel-&gt;createSheet();
  
  //  Attach the newly-cloned sheet to the $objPHPExcel workbook
  $objPHPExcel-&gt;addSheet($objWorkSheet);
  
  // Add some data
  $objPHPExcel-&gt;setActiveSheetIndex($i);
  
  $sheet = $objPHPExcel-&gt;getActiveSheet();
  
  $sheet-&gt;setCellValue('A1', 'Hello'.$i)
          -&gt;setCellValue('B2', 'world!')
          -&gt;setCellValue('C1', 'Hello')
          -&gt;setCellValue('D2', 'world!');
  
  // Rename sheet
  $sheet-&gt;setTitle($i);
  
  $i++;
  }
  </code></pre>
  
  <p>Unfortunately this doesn't work. I only get some sheets of this iteration filled with data and renamed and about the half are empty.</p>
  
  <p>So this is the result (sheet titles):</p>
  
  <p>0, 2, 4, 6, 8, 9, and 5 empty sheets</p>
  
  <p>I can't figure out why only even numbered (and sheet 9) are correct in the result.</p>