PHP Download Export xls format

Source: Internet
Author: User
Tags php download

    //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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.