Reputation: 891
I would like to fill in the empty spaces of a csv column and its in one column using phpexcel I have added a demo for your viewing: The flow check B2 is its not empty go the next B3 if B3 is empty take value from B2.
Here is my attempt could put my code snip but i have posted the same post with a demo and my attemp.
PHP Excel fill in Empty Cells.
Upvotes: 2
Views: 6048
Reputation: 212412
PHPExcel doesn't provide any built-in function for this: it will only change the content of a cell if you explicitly tell it to do so. You'll need to iterate through the worksheet testing for cells that contain a NULL or empty string, and populate them with the value that you want before saving to CSV.
Something like:
for ($i=2;$i<$highestRow;$i++) {
$colB = $objPHPExcel->getActiveSheet()->getCell('B'.$i)->getValue();
if ($colB == NULL || $colB == '') {
$objPHPExcel->getActiveSheet()->setCellValue(
'B'.$i,
$objPHPExcel->getActiveSheet()->getCell('B'.($i-1))->getValue();
);
}
}
Upvotes: 1