I have given var_dump
to $row_data
and all data is coming, but the problem is when I will generate the data by PHPExcel dynamically.
In a table the data is generated, with no apparent problem. I tested it on another table (most of the answers are in English) and only one row is generated and several columns are missing data as well. I gave var_dump
in both ( $row_data
) and the data is all there!
$sql = "SELECT * FROM $tbname WHERE ID<30";
$i = 0;
$rowID = 2;
while($i < count($row_data)) {
$col= 0;
foreach($row_data[$i] as $key=>$value) {
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $rowID, utf8_encode($value));
$col++;
echo $value."<BR/>";
}
$i++;
$rowID++;
}
ob_clean();
header('Content-Type: text/html; charset=UTF-8');
header("Content-type: application/octetstream");
header ("Content-Disposition: attachment; filename=\"{$arquivo}\"" );
header ("Content-Description: PHP Generated Data" );
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');