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.
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
Post a Comment