PHPExcel - Export Missing Row -


can tell me wrong code exports headers ok missing 1 record export. many thanks

$rownumber = 1; //start in cell 1    while ($row = mysql_fetch_assoc($result)) {     $col = 'a'; // start @ column        // returns title row        if ( $rownumber == 1 ){         $headers = array_keys($row);             foreach($headers $header) {             $objphpexcel->getactivesheet()->setcellvalue($col.$rownumber,$header);             $col++;             }         $rownumber++;       }else{ //returns content rows        $col = 'a';        $rownumber         foreach($row $cell) {                   $objphpexcel->getactivesheet()->setcellvalue($col.$rownumber,$cell);                   $col++;                }        $rownumber++;              }   } $objphpexcel->getactivesheet()->removecolumn('a',3); 

you're displaying headers first row retrieved database, not data row....

$rownumber = 1; //start in cell 1    while ($row = mysql_fetch_assoc($result)) {     $col = 'a'; // start @ column          // returns title row     if ( $rownumber == 1 ){         $headers = array_keys($row);         foreach($headers $header) {             $objphpexcel->getactivesheet()->setcellvalue($col.$rownumber,$header);             $col++;         }         $rownumber++;     }     $col = 'a';     foreach($row $cell) {                   $objphpexcel->getactivesheet()->setcellvalue($col.$rownumber,$cell);                   $col++;            }       $rownumber++; } $objphpexcel->getactivesheet()->removecolumn('a',3); 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -