title: import data from excel sheet using codeigniter
body: <p>I want to import sing column of excel sheet into database table name  admin_record and excel sheet is only consist of one column and name of the column is bar codes and rows can be many. </p>
  
  <p>I want to save it in database my table name is admin_record and its consists of only two fields </p>
  
  <ol>
  <li>id (which is primary key)</li>
  <li>bar_code.  </li>
  </ol>
  
  <p>find only this code which i totally cant understand </p>
  
  <pre><code>public function read_file($table = 'admin_record', $filename = 'example.xls') {
  
      $pathToFile = 'uploads/' . $filename;
      $this-&gt;load-&gt;library('Spreadsheet_Excel_Reader');
      $data = new Spreadsheet_Excel_Reader($pathToFile);
      $sql = "INSERT INTO $table (";
      for($index = 1;$index &lt;= $data-&gt;sheets[0]['numCols']; $index++){
      $sql.= strtolower($data-&gt;sheets[0]['cells'][1][$index]) . ", ";
      }
  
      $sql = rtrim($sql, ", ")." ) VALUES ( ";
      for ($i = 2; $i &lt;= $data-&gt;sheets[0]['numRows']; $i++) {
          $valuesSQL = '';
      for ($j = 1; $j &lt;= $data-&gt;sheets[0]['numCols']; $j++) {
          $valuesSql .= "\"" . $data-&gt;sheets[0]['cells'][$i][$j] . "\", ";
      }
      echo $sql . rtrim($valuesSql, ", ")." ) &lt;br&gt;";
      }
  }
  </code></pre>