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.