I am using this code to set cellvalue from database but it does not work.
$excel2 = PHPExcel_IOFactory::createReader('Excel2007');
$excel2 = $excel2->load("test.xlsx"); // Empty Sheet
$excel2->getActiveSheet()->setCellValue('A1', 'Date');
$m=2;
$result=mysqli_query($con,"select * from settings");
while($row=mysqli_fetch_array($result))
{
$chan=$row['channelID'];
$excel2->getActiveSheet()->setCellValue("C$m", $chan);
echo $chan;
echo "<br>";
$m++;
}
But when I change this line to static text it works fine
$excel2->getActiveSheet()->setCellValue("C$m", "static text");
I don't know where I am doing wrong I want to set value from the database any help would be appreciated.