后端:
//导出
if($_GPC['export']==1){
$list_export = pdo_fetchall($sql.$where);
include $this->template('export');
}
前端:
{php echo header('Content-type: application/vnd.ms-excel');}
{php echo header('Content-Disposition: attachment; filename="二维码扫描记录表'.date('Y-m-d H:i').'导出.xls"');}
<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=utf8">
<meta name=ProgId content=Excel.Sheet>
<meta name=Generator content="Microsoft Excel 12">
</head>
<body>
<div id="comm_32218" align=center x:publishsource="Excel">
<table class="table table-hover">
<thead class="navbar-inner">
<tr>
<th>ID</th>
<th>活动</th>
<th>用户</th>
<th>创建时间</th>
<th>积分</th>
<th>成长值</th>
<th>状态</th>
<th>查看</th>
</tr>
</thead>
<tbody>
{loop $list_export $key $v}
<tr class="{$v['status_class']}">
<td>{$v['id']}</td>
<td>{$v['title']}</td>
<td> {$v['mobile']} {$v['usetime']} </td>
<td>{$v['createtime']}</td>
<td>{$v['credit']}</td>
<td>{$v['growth']}</td>
<td>{$v['status_str']}</td>
<td>
<a target="_blank" href="{php echo $_W['siteroot'].'addons/'.$_W['current_module']['name'].'/qrcode/'.$v['bath'].'/'.$v['id'].'.png'}" class="btn btn-success btn-sm">查看二维码</a>
</td>
</tr>
{/loop}
</tbody>
</table>
</div>
</body>
</html>