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 -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -