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

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

WBOY
WBOYOriginal
2016-06-23 14:00:21778browse

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";		}?>

用PHPExcel试试

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