title: Reading from Excel using PHPExcel in CodeIgniter
body: <p>I'm using PHPExcel to read from Excel files in CodeIgniter. Having issues with integrating the following example provided by PHPExcel in their documentations</p>
  
  <p>Here's the code from the example:</p>
  
  <pre><code>&lt;?php
  
  /** Include path **/
  set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/');
  
  /** PHPExcel_IOFactory */
  include 'PHPExcel/IOFactory.php';
  
  
  $inputFileType = 'Excel5';
  //  $inputFileType = 'Excel2007';
  //  $inputFileType = 'Excel2003XML';
  //  $inputFileType = 'OOCalc';
  //  $inputFileType = 'Gnumeric';
  $inputFileName = './sampleData/example1.xls';
  $sheetname = 'Data Sheet #3';
  
  
  class MyReadFilter implements PHPExcel_Reader_IReadFilter
  {
      public function readCell($column, $row, $worksheetName = '') {
          // Read rows 1 to 7 and columns A to E only
          if ($row &gt;= 1 &amp;&amp; $row &lt;= 7) {
              if (in_array($column,range('A','E'))) {
                  return true;
              }
          }
          return false;
      }
  }
  
  $filterSubset = new MyReadFilter();
  
  echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory with a defined reader type of ',$inputFileType,'&lt;br /&gt;';
  $objReader = PHPExcel_IOFactory::createReader($inputFileType);
  echo 'Loading Sheet "',$sheetname,'" only&lt;br /&gt;';
  $objReader-&gt;setLoadSheetsOnly($sheetname);
  echo 'Loading Sheet using filter&lt;br /&gt;';
  $objReader-&gt;setReadFilter($filterSubset);
  $objPHPExcel = $objReader-&gt;load($inputFileName);
  
  echo '&lt;hr /&gt;';
  
  $sheetData = $objPHPExcel-&gt;getActiveSheet()-&gt;toArray(null,true,true,true);
  var_dump($sheetData);
  
  ?&gt;
  </code></pre>
  
  <p>So, integrating the example with CodeIgniter I did the following:</p>
  
  <ol>
  <li><p>Created a function 'importFromExcel()' which is called from a button click in the View.</p>
  
  <pre><code>public function importFromExcel() 
  {
  $this-&gt;load-&gt;library('excel');
  
  $this-&gt;load-&gt;library('Excel/MyReadFilter');
  
  $inputFileType = 'Excel5';
  //  $inputFileType = 'Excel2007';
  $inputFileName = FCPATH.'uploads/khanas.xlsx';
  $sheetname = 'Sheet1';
  
  $filterSubset = new MyReadFilter();
  
  echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory with a defined reader type of ',$inputFileType,'&lt;br /&gt;';
  $objReader = PHPExcel_IOFactory::createReader($inputFileType);
  echo 'Loading Sheet "',$sheetname,'" only&lt;br /&gt;';
  $objReader-&gt;setLoadSheetsOnly($sheetname);
  echo 'Loading Sheet using filter&lt;br /&gt;';
  $objReader-&gt;setReadFilter($filterSubset);
  $objPHPExcel = $objReader-&gt;load($inputFileName);
  
  
  echo '&lt;hr /&gt;';
  
  $sheetData = $objPHPExcel-&gt;getActiveSheet()-&gt;toArray(null,true,true,true);
  var_dump($sheetData);
  }
  </code></pre></li>
  <li><p>Created a library in 'application/libraries' and named it 'MyReadFilter.php'</p>
  
  <pre><code>class MyReadFilter implements PHPExcel_Reader_IReadFilter
  {
  public function readCell($column, $row, $worksheetName = '') {
      $startRow   = 1;
      $endRow     = 7;
      $startCol   = 'A';
      $endCol     = 'E';
  
      // Read rows 1 to 7 and columns A to E only
      if ($row &gt;= $startRow &amp;&amp; $row &lt;= $endRow) {
          if (in_array($column,range($startCol,$endCol))) {
              return true;
          }
      }
      return false;
  }
  }
  </code></pre></li>
  </ol>
  
  <p>When I call the class as below doesn't work. </p>
  
  <pre><code>$this-&gt;load-&gt;library('Excel/MyReadFilter');
  </code></pre>
  
  <p>How do I go about fixing this?</p>