//xls format Download Set_time_limit(0); $line _num= 1; $resultPHPExcel=NewPhpexcel (); $resultPHPExcel->getactivesheet ()->setcellvalue ("A1", ' Business reference number ')); $resultPHPExcel->getactivesheet ()->getcolumndimension (' A ')->setwidth (10);//Set Cell width $resultFillA 1=$resultPHPExcel->getactivesheet ()->getstyle ("A1")->getfill ("A1");//Color $resultFillA 1->setfilltype (Phpexcel_style_fill::fill_solid); $resultPHPExcel->getactivesheet ()->setcellvalue ("B1", ' Payee number '); $resultPHPExcel->getactivesheet ()->getcolumndimension (' B ')->setwidth (10);//Set Cell width $resultFillA 1=$resultPHPExcel->getactivesheet ()->getstyle ("B1")->getfill ("B1");//Color $resultFillA 1->setfilltype (Phpexcel_style_fill::fill_solid); //Font Bold $resultPHPExcel->getactivesheet ()->getstyle (' A1:b1 ')->getfont ()->setbold (true); //Center $resultPHPExcel->getactivesheet ()->getstyle (' A1:b1 ')->getalignment ()->sethorizontal (phpexcel_style_alignment::horizontal_center); $outputFileName=Date(' Y year m D Day h i min ', Time()) . ' Contract information download. xls '; //stepping for each fetch of data $step= 1000; $round=Ceil($count/$step); for($i= 1;$i<=$round;$i++) { $criteria->limit =$step;//Take 1 data, if less than 0, do not process $criteria->offset = ($i-1) *$step;//Two is combined, which means that the limit is offset 1, or the representative. Limit 1,10 $rent _contract_list= T_rent_contract::model ()->findall ($criteria); if(Count($rent _contract_list)) { foreach($rent _contract_list as $rent _contract) { $line _num++; $resultPHPExcel->getactivesheet ()->setcellvalue ("a{$line _num}",$content _a); $resultPHPExcel->getactivesheet ()->setcellvalue ("b{$line _num}",content_b); //$resultPHPExcel->getactivesheet ()->setcellvalueexplicit ("C{$line _num}", $rent _contract->f_rent_ number,phpexcel_cell_datatype::type_string); Bank card account to prevent data formatting from being exported to Excel } } } Define(' Phpexcel_root ',dirname(__file__)); require_oncePhpexcel_root. ' Phpexcel/writer/excel5.php '; $xlsWriter=NewPhpexcel_writer_excel5 ($resultPHPExcel); Header("Content-type:application/force-download"); Header("Content-type:application/octet-stream"); Header("Content-type:application/download"); Header(' Content-disposition:inline;filename= '.$outputFileName. ‘"‘); Header("Content-transfer-encoding:binary"); Header("Expires:mon, 1997 05:00:00 GMT"); Header("Last-modified:".)gmdate("D, D M Y h:i:s"). "GMT"); Header("Cache-control:must-revalidate, post-check=0, pre-check=0"); Header("Pragma:no-cache"); $xlsWriter->save ("Php://output"); Exit;
PHP Download Export xls format