Easy PHP excel output

Source: Internet
Author: User
Tags php excel

To export PHP Data to an excel table, PHP has excellent support in this aspect. 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 "second-level 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 "";

}

?>

Pay attention to the encoding problem, because the table generally outputs UTF-8 encoding. Garbled characters appear when I output data in table form (table + tr + td .... Because my page code is GB2312 and can be converted to iconv, it is best to use the above method to output the code to prevent garbled characters.

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.