Example of simple batch export data for Excel

Source: Internet
Author: User
First you need to download the Phpexecel class file, the Help document can refer to phpexcel Chinese help manual | Phpexcel how to use it.

The following directly on the example, is I write a simple batch export data for Excel example

Front page is relatively simple, is a hyperlink, jump to the processing page, hyperlinks can also be with some parameters (see requirements)!

<a href= "./process1.php" > Export Excel Table </a>

Background process.php page

 Expexcel (, ' phpexcel.php ' =->getproperties ()->setcreator ("Zxf")->setlastmodifiedby ("ZXF")- >settitle (' Data Excel export ')->setsubject (' Data Excel export ')->setdescription (' Export Data ')->setkeywords ("     Excel ")->setcategory (" Result file "); ->setactivesheetindex (0->->setcellvalue (' A1 ', ' owner name '->setcellvalue (' B1 ', ' Password '->setcellvalue (' C1 '), ' Mobile number '->setcellvalue (' D1 ', ' Address '->getstyle (' a1:d1 ')->getfont ()->getcolor ()->setargb (phpexcel_ Style_color:: = 1 (++->->setcellvalue (' A '., [' Name '->setcellvalue (' B '), [' pwd '->setcellvalue (' C '., ['   Phone '->setcellvalue (' D '., [' Address '->setactivesheetindex (0 (' content-type:application/vnd.ms-excel '); (' Content-disposition:attachment;filename= '.     XLS "');    (' Cache-control:max-age=0 ' (' content-type:text/html; Charset=utf-8 ');      = Phpexcel_iofactory::createwriter (, ' Excel5 '); ->save (' Php://output ' ("Content-type:text/html;charset=utf-8") = @ (' localhost ', ' root ', ') or (' Connection database failed ' (' Test ', (' set names UTF8 ' = "select * from House" = (= (= (= (= [] = "User table" Expexc El (,)

Use Phpexcel to export data to this end, for use Phpexcel import to the database can see Using PHPEXCEL implementation data batch upload to the database

Related Article

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.