for the time being and according to the doc there is no method to append new cell, you can only append new rows
Laravel Excel - How to add cell to each row?
Hi,
Using Laravel excel package I would like to load an existing csv file and the for each row add some data in custom column/cell
I can load a file like below and I can the target the first sheet. I can then choose a specific cell to update and export.
Excel::load($tempFile, function($doc) {
$sheet = $doc->setActiveSheetIndex(0);
$sheet->setCellValue('D5', 'Test');
})->export('csv');
How can I target the end of each row (when I don't know how many columns there will be)
Something like the following...
Excel::load($tempFile, function($doc) {
$sheet = $doc->setActiveSheetIndex(0);
foreach($sheet->rows as $row){
$row->appendCell('Some custom data');
}
})->export('csv');
Does anyone have any experience doing that?
Thanks.
@InaniELHoussain Yes you are right. To get around this, I have had to grab the contents of the file into a collection , then append the required data then finally creating a new csv export.
Please or to participate in this conversation.