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