Home > php教程 > php手册 > PHP生成Excel文件的简单方法(附代码)

PHP生成Excel文件的简单方法(附代码)

PHPz
Release: 2018-10-19 15:37:02
Original
1092 people have browsed it

生成excel文件,最简单的莫过于把数据库的数据导入到excel就行了,下面有个不错的示例,大家可以参考下

生成excel 当然使用的是 phpExcel这个类库了,可是它太麻烦了,对于只要简单生成来说有点不值得

什么叫简单,把数据库的数据导入到excel就行了, 这个就是简单了

下面看一段代码(代码来自网络)

注意要双引号的字符串

代码如下:

<?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"; 
?>
Copy after login

运行就会下载test.xls这个文件,打开以后他是这样的

abc.jpg 

 

【相关教程推荐】

1. php编程从入门到精通全套视频教程
2. php从入门到精通 
3. bootstrap教程

Related labels:
php
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template