Home  >  Article  >  Backend Development  >  Implementation method of PHP outputting EXCEL through table tag_PHP tutorial

Implementation method of PHP outputting EXCEL through table tag_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:00:00902browse

Key code:

Copy code The code is as follows:

header("Content-type:application /vnd.ms-excel");
header("Conten-Disposition:filename=hp.xlsx");
?>

The first sentence is used to declare the file The format of the content; the second round is used to modify the file name. Without the second statement, the generated file will have no suffix.
Implementation code:
Copy code The code is as follows:


header("Content-type:application/vnd.ms-excel");
header("Conten -Disposition:filename=hp.xlsx");
?>






< td>Name









                                                                                   >
Of course, we naturally thought, can the contents of the database be output to the table in this way?
The answer is yes.
Implementation code:

Copy code

The code is as follows:

header("Content-type:application/vnd.ms-excel");header("Content-Disposition :filename=qianshou.xls");mysql_connect("localhost","root","");
mysql_select_db("test");
mysql_query("SET NAMES GBK");
$query="select * from city ";
$r=mysql_query($query);
?>
i love you
Number Age
1 test20
2









while($row=mysql_fetch_assoc($r)){
?>





}
?>
City list
idp_idname
< ?php echo $row[id] ?> < ?php echo $row[c_name]?>








http://www.bkjia.com/PHPjc/328101.html

www.bkjia.comtrue

http: //www.bkjia.com/PHPjc/328101.htmlTechArticleKey code: Copy the code as follows: ?php header("Content-type:application/vnd.ms-excel "); header("Conten-Disposition:filename=hp.xlsx"); ? The first sentence is used to declare the content of the file...
Statement:
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