Use php to generate an excel file _ PHP Tutorial

Source: Internet
Author: User
Use php to generate an excel file. Nbsp; use php to generate an excel file haha. today I want to learn more. It is too simple to generate an excel file in php. it is estimated that all of you will use it, so it is shared. Let's look at the code :? Header (Conten nbsp; use php to generate an excel file
Haha, I learned another trick today. It is too easy to generate an excel file using php, so
Shared.
Let's look at the code:
Header ("Content-type: application/vnd. ms-excel ");
Header ("Content-Disposition: filename=test.xls ");
Echo "test1 ";
Echo "test2 ";
Echo "test1 ";
Echo "test2 ";
Echo "test1 ";
Echo "test2 ";
Echo "test1 ";
Echo "test2 ";
Echo "test1 ";
Echo "test2 ";
Echo "test1 ";
Echo "test2 ";
?>
When you run the above code in the php environment, you can see the browser asking you if you want to download the excel
Document. click Save. an excel file is added to the hard disk.
The final result is good.
In fact, when doing real applications, you can extract the data from the database and
Add a column of data after the end, and add the echo method after each row of data.
Use header ("Content-type: application/vnd. ms-excel ");
Excel file, with header ("Content-Disposition: filename=test.xls"); table
The output file name is text.xls. In this case, OK.
We can modify the header so that it can output more files in different formats.
File is more convenient.

Yorgo Sun (yorgo@163.net)
2000/11/14
You are welcome to reprint the document, but please ensure that the document is complete and notify the author. Thank you :-)


Haha, I learned another trick today. It is too simple to generate an excel file in php. it is estimated that all of you will use it, so it is shared. Let's look at the code :? Header (Conten...

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.