Easy PHP output excel

Source: Internet
Author: User
Keywords Network programming PHP tutorial
Tags application code content data echo network network programming php

To output PHP data to an excel spreadsheet, PHP has great support in this area, and PHP can output a simple excel form 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". "t";

echo "username". "t";

echo "password". "t";

echo "second-level domain name." "t";

echo "n";

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

echo "$ val-> ComName". "t";

echo "$ val-> UserName". "t";

echo "$ val-> UserTruePw". "t";

echo emptyempty ($ val-> DoMainName)? '': ('http: //'.$val-> DoMainName.'. jiaomai.com '). "t";

echo "n";

}

?>

Pay attention to coding problems, because the form output is utf-8 encoding. I use the form of the form (table + tr + td) output when there garbled. . . . Because I page coding is GB2312, available iconv turn line, in order to prevent garbled themselves and engage in uncertainty, it is best to use the above output.

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.