Recommand · June 10, 2021 0

import phpexcel codeigniter except current cell value

i want to import from excel using php excel from my codeigniter with current cell containt current text

cell1 cell2
A 1
B 2
C 3

i want just cell except B in cell1 to insert database

my controller

public function import_excel(){
    if (isset($_FILES["fileExcel"]["name"])) {
        $path = $_FILES["fileExcel"]["tmp_name"];
        $object = IOFactory::load($path);
        foreach($object->getWorksheetIterator() as $worksheet)
        {
            $highestRow = $worksheet->getHighestRow();
            $highestColumn = $worksheet->getHighestColumn();    
            for($row=2; $row<=$highestRow; $row++)
            {
                $cell1= $worksheet->getCellByColumnAndRow(0, $row)->getValue();
                $cell2= $worksheet->getCellByColumnAndRow(1, $row)->getValue();
                
                $temp_data[] = array(
                    'cell1'  => $cell1,
                    'cell2'   => $cell2,
                    
                );
                

            }
        }
        
        if($cell1 == 'B'){

        }else{
            $this->load->model('M_Admin');
            $insert = $this->M_Admin->insert($temp_data);
            
        }

but this failed and data still insert. please help me and many thanks you for help.