php - How can I rewrite this code for maatwebsite/excel? -


i using laravel. want read excel file , add new column left of first column on each sheet using php. (the excel file can have many 10 sheets)

concatenate "afs-" data in each row of first column , store new string in new column left.

eg. enter image description here

code below.

        $finalfile = "";         /** load $inputfilename phpexcel object **/         $objphpexcel = phpexcel_iofactory::load($inputfilename);          foreach ($objphpexcel->getworksheetiterator() $worksheet)          {             $worksheet->insertnewcolumnbefore('a', 1); //to insert single new column before column a:              foreach($worksheet->getrowiterator() $row)              {                 $worksheet->setcellvalue('a'.$row, 'afs-' . $worksheet->getcell("b".$row)->getvalue());             }         }          $convertedfilename = "converted-file". $date->gettimestamp().".xlsx";         $objwriter = new phpexcel_writer_excel2007($objphpexcel);         $objwriter->save($directory . $convertedfilename); 


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -