Im about the create script that exports data from mysql database and save it to excel file(multisheet). I need to have the cells dinamically genereted. The script does the headings correctly, but the data set is empty. I checked the data is there when i "echo" the $value variable. so it should have work.
Any help would appriciated. Thanks a lot.
// Add new sheet
$objWorkSheet = $objPHPExcel->createSheet($i); //Setting index when creating
//Write heading cells
$c=0;
foreach ($res['name'] as $name) {
$objWorkSheet->setCellValueByColumnAndRow($c, 1, $name);
$c++;
}
//Write data cells
$rowcount = 2; // 2-to skip the header
while($celldata = mysql_fetch_assoc($qry)) {
$col=0;
foreach($celldata as $key=>$value){
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col,$rowcount,$value);
$col++;
}
$rowcount++;
$col=0;
}
// Rename sheet
$objWorkSheet->setTitle("$title");