?
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 to ask the user whether to download the Excel document, click Save, the hard drive on the more than an Excel file, use Excel to open will see the final results, how good it.
In fact, when doing real application, you can take the data out of the database, and then after each column of data plus \ t, after each row of data added \ n method echo out, in the beginning of PHP with header ("content-type:application/ Vnd.ms-excel "); indicates that the output is an Excel file, with the 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 PHP is more convenient for processing various types of files.
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.