1
I gave one var_dump
in the $row_data
and all the data is coming, but the problem is when I will generate the data by Phpexcel dynamically.
In a table the data is generated, without any apparent problem. I tested in another table (most answers are in English) and only one row is generated and several columns are without data as well. I gave a 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');
Pq the
while
? only the foreach does not solve?$key
is being used for something?– rray
How are you using mysql? Your
while
are usingcount
in $row_data, this variable is fetchAll or fetch_assoc?– Guilherme Nascimento
I am using $sth->fetchAll(PDO::FETCH_ASSOC); (I gave a
return
in it)– Denali
$rowID
was set before the while?– rray
yes it was set, I updated the topic too.
– Denali
I tested again: in a table the data is generated, without any apparent problem. I tested in another table (most answers are English) and only one row is generated and several columns are without data as well. gave a var_dump on both ($row_data) and the data is all there!
– Denali
When you press
f2
in these blank cells appears something? can be the formatting of it. could put a couple of items of the array for us to know how it is organized?– rray