Home > Backend Development > PHP Tutorial > thinkphp如何把表格导出成excel形式

thinkphp如何把表格导出成excel形式

WBOY
Release: 2016-06-23 14:00:21
Original
833 people have browsed it

thinkphp如何把表格导出成excel形式


回复讨论(解决方案)

百度一搜 一大把啊

百度一搜 一大把啊
搜的都是后台PHP方法,前台页面表格的数据怎样传到后台没说

前台页面就是后台生成的,如果找到生成前台的sql的话有个原始的方法能生成对应的excel
范例如下

include_once 'DB_connmssql.php';header("Content-Type:text/html;charset=utf-8");header("Content-type:application/vnd.ms-excel");header("Content-Disposition:attachment;filename=tt-".date('Y-m-d',time()).".xls");//定义生成的文件名$sql="xxx ";$query = mssql_query($sql_initbest);$x=1;while($row=mssql_fetch_array($query)){	if($x>=1){//生成excel的列名		echo iconv("utf-8","gbk",'Store Code')."\t";		//。。。。。		echo iconv("utf-8","gbk",'% of total quantity sold')."\t";				$x--;	}	//$row['Store_name']=iconv('gb2312','utf-8',$row['Store_name']); 表中有中文需要像这样处理		echo "\n";//以下为生成行	echo iconv("utf-8","gbk",$row['Store_number'])."\t";		//。。。。。	echo iconv("utf-8","gbk",$row['other_pss'])."\t";		}?>
Copy after login

用PHPExcel试试

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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template