php - Phpexcel xls file showing garbage data while downloading -


i using phpexcel 1.8.0 in project. when want generate , download .xls file data database, file downloaded garbage data. here code:

$result = mysql_query("select * my_table"); ob_start();    //excel code   $this->load->library('excel');  //activate worksheet number 1         $this->excel->setactivesheetindex(0); //name worksheet     $this->excel->getactivesheet()->settitle('test worksheet');      $rownumber = 5;     while ($row = mysql_fetch_assoc($result)) {       $col = 'b';         foreach ($fields $cell) {             $this->excel->getactivesheet()->setcellvalue($col .$rownumber, $row[$cell]);             $col++;         }          $rownumber++;     }        // ob_end_clean();     //  ob_clean() ;          $filename='report.xls'; //save our workbook file name     header('content-type: application/vnd.ms-excel'); //mime type     header('content-disposition: attachment;filename="'.$filename.'"');      header('cache-control: max-age=0'); //no cache      $objwriter = phpexcel_iofactory::createwriter($this->excel, 'excel5'); $objwriter->save('php://output');   exit();  

i have used both ob_end_clean() , ob_clean() nothing works.

try code:

$objwriter = phpexcel_iofactory::createwriter($objphpexcel, 'excel5'); ob_end_clean(); $objwriter->save('php://output'); 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -