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 />