Generate Excel files with PHP
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 asks the user whether to download the Excel document, click Save, the hard disk on the more than one Excel file, using Excel Open will see the final result, how good it.
In fact, when doing real applications, you can take the data out of the database, and then follow the end of each column to add \ t, after each line of data to add \ n method echo out, at the beginning of PHP with the header ("content-type:application/ Vnd.ms-excel "), indicating that the output is an Excel file, with the header (" Content-disposition:filename=test.xls "), and that the output file name is Text.xls. This will be OK.
We can also modify the header to let him output more files in the format, so PHP is more convenient to handle various types of files.
http://www.bkjia.com/PHPjc/314998.html www.bkjia.com true http://www.bkjia.com/PHPjc/314998.html techarticle generate Excel files in PHP? 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; E ...