PHP, do not use COM, generate Excel file _php tutorial

Source: Internet
Author: User
Generate Excel files with PHP

Header ("Content-type:application/vnd.ms-excel");
Header ("Content-disposition:filename=test.xls");
echo "Test1\t";
echo "test2\t\n";
echo "Test1\t";
echo "test2\t\n";
echo "Test1\t";
echo "test2\t\n";
echo "Test1\t";
echo "test2\t\n";
echo "Test1\t";
echo "test2\t\n";
echo "Test1\t";
echo "test2\t\n";
?>
In the PHP environment to run the above code, you can see the browser asks the user whether to download the Excel document, click Save, the hard disk on the more than one Excel file, using Excel Open will see the final result, how good it.
In fact, when doing real applications, you can take the data out of the database, and then follow the end of each column to add \ t, after each line of data to add \ n method echo out, at the beginning of PHP with the header ("content-type:application/ Vnd.ms-excel "), indicating that the output is an Excel file, with the header (" Content-disposition:filename=test.xls "), and that the output file name is Text.xls. This will be OK.



We can also modify the header to let him output more files in the format, so PHP is more convenient to handle various types of files.

http://www.bkjia.com/PHPjc/314998.html www.bkjia.com true http://www.bkjia.com/PHPjc/314998.html techarticle generate Excel files in PHP? header (Content-type:application/vnd.ms-excel); header (Content-disposition:filename=test.xls); Echo test1\t; Echo test2\t\n; Echo test1\t; Echo test2\t\n; E ...

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