Easy implementation of PHP output excel_php tutorial

Source: Internet
Author: User
To output PHP data to Excel tables, PHP supports this very well, and PHP can output a simple Excel table in just a few simple sentences.

PHP Code:

   Header ("Content-type:application/vnd.ms-excel");

Header ("Content-disposition:attachment;filename=users.xls");

echo "Company name". "";

echo "User name". "";

echo "Password". "";

echo "Level two domain name". "";

echo "";

foreach ($result [result] as $val) {

echo "$val->comname". "";

echo "$val->username". "";

echo "$val->usertruepw". "";

Echo emptyempty ($val->domainname)?:( http://. $val->domainname. jiaomai.com). "";

echo "";

}

?>

Note the coding problem because the general output of the table is UTF-8 encoded. I use tabular form (TABLE+TR+TD) output when there is garbled .... Because my page encoding is GB2312, can be used iconv turn also line, in order to prevent garbled oneself again, it is best to use the above method output.

http://www.bkjia.com/PHPjc/486264.html www.bkjia.com true http://www.bkjia.com/PHPjc/486264.html techarticle to output PHP data to Excel tables, PHP supports this very well, and PHP can output a simple Excel table in just a few simple sentences. PHP Code: Header (Content-type:applicati ...

  • 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.