Phpexcel is not exporting some data

Asked

Viewed 47 times

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');
  • 1

    Pq the while? only the foreach does not solve? $keyis being used for something?

  • How are you using mysql? Your while are using count in $row_data, this variable is fetchAll or fetch_assoc?

  • I am using $sth->fetchAll(PDO::FETCH_ASSOC); (I gave a return in it)

  • $rowID was set before the while?

  • yes it was set, I updated the topic too.

  • 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!

  • 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?

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.