Using Phpexcel to export data in batches

Source: Internet
Author: User

if(isset($_post[' Export ']) &&$_post[' export '] = = ' Exporting selected data '){    //This is the check box for the selected data    $export _id=$_post[' Choose ']; if($export _id! = ")    {        $str=implode(",",$export _id); $sql= "SELECT *" from the page WHERE ID in ($str)"; $result=Mysqli_query($link,$sql); if($result)        {             while($row=Mysqli_fetch_assoc($result))            {                $page _info[] =$row; }        }            /** Introduction of Phpexcel*/        include(".. /classes/phpexcel.php "); include(".. /classes/phpexcel/writer/excel2007.php "); //Create an Excel file Object        $objPHPExcel=NewPhpexcel (); //Document Information, click on the table right mouse button to view the properties you can see        $objPHPExcel->getproperties ()->setcreator ("Paper Database Center")            ->setlastmodifiedby ("Excel Document")            ->settitle ("Excel Document")            ->setsubject ("Excel Document")            ->setdescription ("Excel Document from Paper Database Center")            ->setkeywords ("Excel OpenXML php")            ->setcategory ("Excel Export result file"); //Add data according to Excel coordinates        $objPHPExcel->setactivesheetindex (0)            ->setcellvalue (' A1 ', ' Serial number '))            ->setcellvalue (' B1 ', ' title ')            ->setcellvalue (' C1 ', ' author '); //Add Table Contents        foreach($page _info  as $k=$v) {            $num=$k+ 2; $objPHPExcel->setactivesheetindex (0)                ->setcellvalue (' A '.$num, ++$k)                ->setcellvalue (' B ').$num,$v[' title '])                ->setcellvalue (' C ').$num,$v[' Author ']); }        //Renaming work Sheet        $objPHPExcel->getactivesheet ()->settitle (' Export data '); //set the first sheet to work sheet        $objPHPExcel->setactivesheetindex (0); //Save the Excel 95 format file, save the path to the current path,//$objWriter = Phpexcel_iofactory::createwriter ($objPHPExcel, ' Excel5 '); $objWriter->save (' Export.xls ');        Ob_end_clean(); Header(' Content-type:application/vnd.ms-excel;charset=utf-8 '); Header(' content-disposition:attachment;filename= ' Export.xls "'); //header (' cache-control:max-age=0 ');        $objWriter= Phpexcel_iofactory::createwriter ($objPHPExcel, ' Excel5 '); $objWriter->save (' Php://output '); }    Else    {        Echo"<script>alert (' No data selected, please re-select! '); History.go ( -1);</script> "; }}   

Using Phpexcel to export data in batches

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.