Home  >  Article  >  php教程  >  php 简单生成 excel文件

php 简单生成 excel文件

WBOY
WBOYOriginal
2016-06-06 20:02:09776browse

生成excel 当然使用的是 phpExcel这个类库了,可是它太麻烦了,对于只要简单生成来说有点不得 什么叫简单,把数据库的数据导入到excel就行了, 这个就是简单了 下面看一段代码(代码来自网络) 注意要双引号的字符串 ?phpheader(Content-type:application/vnd.ms-e

生成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"; 
?> 

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

php 简单生成 excel文件


一看就会的代码,加简单的图片

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
Previous article:php socket编程Next article:用VIM做PHP开发环境