nbsp Generate Excel files in PHP
Haha, learn another trick today. PHP to generate Excel documents is too simple, it is estimated that everyone will use, so
Shared out.
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";
?>
In the PHP environment to run the above code, you can see the browser to ask users whether to download Excel
Document, click Save, on the hard drive on a more than one Excel file, use Excel to open it will see
The end result, how good it is.
In fact, when doing a real application, you can take the data out of the database, and then follow each
After a column of data is added, each row of data after the addition of the method echo out, at the beginning of PHP
With header ("Content-type:application/vnd.ms-excel"), indicating that the output is
Excel file, with header ("Content-disposition:filename=test.xls");
The file name for the output is Text.xls. That's OK.
We can also modify the header to let him output more format files so that PHP handles various types of
File is more convenient.
Yorgo Sun (yorgo@163.net)
2000/11/14
Welcome to reprint, but please ensure that the document is complete, notify the author. Thanks,:-).
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.