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 demo:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<table width="200" border="1">
<tr>
<td>Apple</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>Banna</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<p> </p>
<p>The final outcome</p>
<table width="200" border="1">
<tr>
<td>Apple</td>
</tr>
<tr>
<td>Apple</td>
</tr>
<tr>
<td>Apple</td>
</tr>
<tr>
<td>Banna</td>
</tr>
<tr>
<td>Banna</td>
</tr>
</table>
<p> </p>
</body>
</html>
This is what i have come up with please help. its just one column i want to populate any empty fields
<?php
include'../Classes/PHPExcel.php';
include'../Classes/PHPExcel/IOFactory.php';
$objReader = new PHPExcel_Reader_CSV();
$objReader->setSheetIndex(0);
$objPHPExcel = $objReader->load('../Output/Basefile121101_2238.csv');
$highestRow = $objPHPExcel->getActiveSheet()->getHighestRow();
$COLB="";
$COLB3=$objPHPExcel->getActiveSheet()->getCell('B3')->getValue();
echo $COLB;
for ($i=2;$i<$highestRow;$i++){
if($COLB!=""){
$COLB=$objPHPExcel->getActiveSheet()->getCell('B'.$i)->getValue();
$valcol=$COLB;
$SETVAL=$objPHPExcel->getActiveSheet()->setCellValue('B'.$i, $valcol);
/*$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV');
$objWriter->save('../Output/Basefile121101_2238.csv');*/
echo $valcol=$COLB."<br>";
}
else{
$counter=0;
$counter++;
$results=$i-$counter;
$COLB=$objPHPExcel->getActiveSheet()->getCell('B'.$i)->getValue();
$valcol=$COLB;
$SETVAL=$objPHPExcel->getActiveSheet()->setCellValue('B'.$results, $valcol);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV');
$objWriter->save('../Output/Basefile121101_2238.csv');
}
}
?>