title: How do I read sheet two of an xlsx file with PHPExcel?
body: <p>I know how to read my xlsx spreadsheet and loop through the first sheet.</p>
  
  <p>It has 5 sheets and I am having trouble getting to any other than the first.</p>
  
  <p>Here is the code I am using which was straight from the documentation.
  You can see I tried to utilize setActiveSheet, but that threw the error <code>Call to undefined method PHPExcel::setActiveSheet()</code>.</p>
  
  <p><strong>Code</strong>:</p>
  
  <pre><code>$objReader = PHPExcel_IOFactory::createReader('Excel2007');
  $objReader-&gt;setReadDataOnly(true);
  $objPHPExcel = $objReader-&gt;load("cmt_school_data.xlsx");
  //$objPHPExcel-&gt;setActiveSheet(1);
  $objWorksheet = $objPHPExcel-&gt;getActiveSheet();
  
  echo '&lt;table border=1&gt;' . "\n";
  
  foreach ($objWorksheet-&gt;getRowIterator() as $row) {
  
    echo '&lt;tr&gt;' . "\n";
  
    $cellIterator = $row-&gt;getCellIterator();
  
    // This loops all cells, even if it is not set.
    // By default, only cells that are set will be iterated.
    $cellIterator-&gt;setIterateOnlyExistingCells(false);
  
    foreach ($cellIterator as $cell) {
      echo '&lt;td&gt;' . $cell-&gt;getValue() . '&lt;/td&gt;' . "\n";
    }
  
    echo '&lt;/tr&gt;' . "\n";
  
  }
  
  echo '&lt;/table&gt;' . "\n";
  </code></pre>