title: phpexcel codeigniter Validation check if cells in one row empty or not
body: <p>I have 'import from excel' function in my codeigniter 3 using phpexcel, but i want to create a validation system to check if some cells are empty or not and can detect which column and row is that before the data can be imported into my database. And if detected, import function should stop.</p>
  
  <p>here's the controller :</p>
  
  <pre><code>public function do_upload(){
  
  
      $config['upload_path'] = './tempDat/';
      $config['allowed_types'] = 'xlsx|xls';
  
      $this-&gt;load-&gt;library('upload', $config);
  
      if ( ! $this-&gt;upload-&gt;do_upload()){
          $error = array('error' =&gt; $this-&gt;upload-&gt;display_errors());
      }
      else{
          $data = array('upload_data' =&gt; $this-&gt;upload-&gt;data());
          $upload_data = $this-&gt;upload-&gt;data(); 
          $filename = $upload_data['file_name'];
          $this-&gt;client-&gt;upload_data($filename);
        //  unlink('./tempDat/'.$filename);
          redirect('client/upload','refresh');
      }
  }
  </code></pre>
  
  <p>here's the model i already tried :</p>
  
  <pre><code>public function upload_data($filename){
      ini_set('memory_limit', '-1');
      $inputFileName = './tempDat/'.$filename;
      try {
      $objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
      } catch(Exception $e) {
      die('Error loading file :' . $e-&gt;getMessage());
      }
  
      $worksheet = $objPHPExcel-&gt;getActiveSheet()-&gt;toArray(null,true,true,true);
  
      $numRows = count($worksheet);
  
      $objWorksheet = $objPHPExcel-&gt;getActiveSheet();
      $highestRow = $objWorksheet-&gt;getHighestRow(); 
      $highestColumn = $objWorksheet-&gt;getHighestColumn(); 
  
  
      for ($i=2; $i &lt; ($numRows+1) ; $i++) { 
  
         $test = $objPHPExcel-&gt;getActiveSheet()-&gt;rangeToArray('A1:A'.$i);
   if( $test != NULL ) {  
  
          $ins = array(
                  "eng_code"          =&gt; $worksheet[$i]["B"],
                  "name_1"          =&gt; $worksheet[$i]["C"],
                  "name_2"          =&gt; $worksheet[$i]["D"],
                  "divisi"          =&gt; $worksheet[$i]["E"],
                  "title"          =&gt; $worksheet[$i]["F"],
                  "sex"                       =&gt; $worksheet[$i]["G"],
                  "date_of_birth"          =&gt; $worksheet[$i]["H"],
                  "date_of_commencement"          =&gt; $worksheet[$i]["I"],
                  "salary_min_1"          =&gt; $worksheet[$i]["J"],
                  "allowance_min_1"          =&gt; $worksheet[$i]["K"],
                  "salary"          =&gt; $worksheet[$i]["L"],
                  "allowance"          =&gt; $worksheet[$i]["M"],
                  "termination_date"          =&gt; $worksheet[$i]["N"],
                  "type_of_termination"          =&gt; $worksheet[$i]["O"],
                  "manfaat_termination"          =&gt; $worksheet[$i]["P"],
                  "basic_salary_at"          =&gt; $worksheet[$i]["Q"],
                  "basic_allowance_at"          =&gt; $worksheet[$i]["R"],
                  "status_employee_min_1"          =&gt; $worksheet[$i]["S"],
                  "status_employee"          =&gt; $worksheet[$i]["T"],
  
  
                 );
  
  
           $this-&gt;db-&gt;insert('tb_eec', $ins);
      } else {
  
          if( $test == NULL || $test == '') {
  
           $this-&gt;session-&gt;set_flashdata('pesan', '&lt;div style="color:blue;"&gt;&lt;b&gt;Kolom '.$worksheet[1]["A"].' Baris '.$i.' Belum diisi !&lt;/b&gt;&lt;/div&gt;');
  
           }
      }
      }
  }
  </code></pre>
  
  <p>i tried many different way but the result is always the same, my function always continue to import the data even though some cells are empty.</p>
  
  <p>help me please :)</p>