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

thinkphp怎么把表格导出成excel形式

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 11:52:08
Original
1112 people have browsed it

thinkphp如何把表格导出成excel形式
thinkphp如何把表格导出成excel形式
------解决方案--------------------
前台页面就是后台生成的,如果找到生成前台的sql的话有个原始的方法能生成对应的excel
范例如下

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

------解决方案--------------------
用PHPExcel试试

Related labels:
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