i have elements in an array and I would like to put the values in a column but start inserting in cell 2. for example Column E start inserting E2 going down to E6.
Here is an example code I have tried:
foreach($distinctresults as $distinctres)
{
$distinctnow[]=$distinctres;
}
for($i=1;$i<=6;$i++){
$objPHPExcel->getActiveSheet()->setCellValue('E'.$i,$distinctnow[$i]);
}
if I add another loop starting with 2 to cater for the row number in E it throws a offset error.
This’d be how you adjust the cell references
but note that your $distinctnow array will actually have keys 0->5 (assuming 6 data points), and you’re looping over 1->6, so you’re missing an item. How about: