title: Fatal error CodeIgniter: Class 'PHPExcel_IOFactory' not found
body: <p>I am working on a project in which I need to import data form an Excel (.xlsx) file into a table in database.</p>
  
  <p>I already wrote code for a controller, import.php:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>if($this-&gt;input-&gt;post('send')=='add'):
      $config['upload_path'] =  'media/result';
      //Only allow this type of extensions 
      $config['allowed_types'] = 'xlsx|csv';
      $this-&gt;load-&gt;library('upload', $config);
      // if any error occurs 
      if ( ! $this-&gt;upload-&gt;do_upload('upload_file1'))
      {
          $error = array('error' =&gt; $this-&gt;upload-&gt;display_errors());
      }
      //if successfully uploaded the file 
      else
      {
          $upload_data = $this-&gt;upload-&gt;data();
          $file_name = $upload_data['file_name'];
          //load library phpExcel
          $this-&gt;load-&gt;library("Excel");
          //here i used microsoft excel 2007
          $objReader = PHPExcel_IOFactory::createReader('Excel2007');
          //set to read only
          $objReader-&gt;setReadDataOnly(true);
          //load excel file
          $objPHPExcel = $objReader-&gt;load('upload/'.$file_name);
          $sheetnumber = 0;
          foreach ($objPHPExcel-&gt;getWorksheetIterator() as $sheet)
          {
              $s = $sheet-&gt;getTitle(); // get the sheet name 
              $sheet= str_replace(' ', '', $s); // remove the spaces between sheet name 
              $sheet= strtolower($sheet); 
              $objWorksheet = $objPHPExcel-&gt;getSheetByName($s);
              $lastRow = $objPHPExcel-&gt;setActiveSheetIndex($sheetnumber)-&gt;getHighestRow(); 
              $sheetnumber++;
  
              if($sheet=='student')// if sheet name is student 
              {
                  //loop from first data until last data
                  for($j=2; $j&lt;=$lastRow; $j++)
                  {
                      $classement = $objWorksheet-&gt;getCellByColumnAndRow(1,$j)-&gt;getValue();
                      $dossard = $objWorksheet-&gt;getCellByColumnAndRow(2,$j)-&gt;getValue();
                      $nom = $objWorksheet-&gt;getCellByColumnAndRow(3,$j)-&gt;getValue();
                      $sexe = $objWorksheet-&gt;getCellByColumnAndRow(4,$j)-&gt;getValue();
                      $cat = $objWorksheet-&gt;getCellByColumnAndRow(5,$j)-&gt;getValue();
                      $pays = $objWorksheet-&gt;getCellByColumnAndRow(6,$j)-&gt;getValue();
                      $temps = $objWorksheet-&gt;getCellByColumnAndRow(7,$j)-&gt;getValue();
                      $tempsreel = $objWorksheet-&gt;getCellByColumnAndRow(8,$j)-&gt;getValue();
                      $ecart = $objWorksheet-&gt;getCellByColumnAndRow(9,$j)-&gt;getValue();
                      $moyenne = $objWorksheet-&gt;getCellByColumnAndRow(10,$j)-&gt;getValue();
                      if($classement != '' || $dossard != ''|| $nom != ''|| $sexe != '' || $cat != '' || $pays != '' || $temps != '' || $tempsreel != '' || $ecart != '' || $moyenne != '')
                      {
                          $excel = array(
                              'Classement'=&gt;$classement,
                              'dossard'=&gt;$dossard,
                              'nomprenom'=&gt;$nom,
                              'sexe'=&gt;$sexe,
                              'cat'=&gt;$cat,
                              'pays'=&gt;$pays,
                              'temps'=&gt;$temps,
                              'temspreel'=&gt;$tempsreel,
                              'ecart'=&gt;$ecart,
                              'moyenne'=&gt;$moyenne
                          );
                          $this-&gt;db-&gt;insert('mt_result',$excel);
                          $result=($this-&gt;db-&gt;affected_rows()!= 1)? false:true;
                          if($result == true)
                          {
                              $this-&gt;session-&gt;set_flashdata('msg', 'Member Details Uploaded Successfully');
                              redirect('Result/');
                          }
                          else
                          {
                              $this-&gt;session-&gt;set_flashdata('msg1', 'Member Details Uploading Failed');
                              redirect('Result/');
                          }
                      }
                      else
                      {
                          $this-&gt;session-&gt;set_flashdata('msg1', 'Failed To Upload!Contents are not Matched');
                          redirect('Result/');
                      }  
                  }// loop ends 
              }
          }
      }
  endif; </code></pre>
  </div>
  </div>
  </p>
  
  <p>Whenever I call this controller I get the following error:</p>
  
  <blockquote>
    <p>A PHP Error was encountered</p>
    
    <p>Severity: Error</p>
    
    <p>Message: Class 'PHPExcel_IOFactory' not found</p>
    
    <p>Filename: controllers/Result.php</p>
    
    <p>Line Number: 229</p>
  </blockquote>
  
  <p><strong>How to solve this problem?</strong></p>