Home > Backend Development > PHP Tutorial > PHP, without COM, generate excel files_PHP tutorial

PHP, without COM, generate excel files_PHP tutorial

WBOY
Release: 2016-07-21 16:07:56
Original
795 people have browsed it

Use php to generate excel files

header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:filename=test.xls" );
echo "test1t";
echo "test2tn";
echo "test1t";
echo "test2tn";
echo "test1t";
echo "test2tn";
echo "test1t";
echo "test2tn";
echo "test1t";
echo "test2tn";
echo "test1t";
echo "test2tn";
?>
Run the above code in the php environment, and you can see the browser asking the user whether to download the excel document. Click Save. There will be an extra excel file on the hard disk. Open it with excel and you will see the final result. The result is pretty good.
In fact, when making real applications, you can take the data out of the database, and then echo it out by adding t at the end of each column of data and n at the end of each row of data. Use header( at the beginning of php "Content-type:application/vnd.ms-excel"); indicates that the output is an excel file. Use header("Content-Disposition:filename=test.xls"); to indicate that the output file name is text.xls. That's OK.



We can also modify the header to allow it to output files in more formats, so that PHP will be more convenient in processing various types of files.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/314998.htmlTechArticleUse php to generate excel files? header(Content-type:application/vnd.ms-excel); header(Content -Disposition:filename=test.xls); echo test1t; echo test2tn; echo test1t; echo test2tn; e...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template