php部分
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:attachment;filename=Export_test.xlsx");
$OutputExcel = S(‘OutputExcel‘);
$this->assign(‘OutputExcel‘,$OutputExcel)->display(‘test‘);
html部分
<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">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
<style id="Classeur1_16681_Styles"></style>
</head>
<body>
<div id="Classeur1_16681" align=center x:publishsource="Excel">
<table x:str border=0 cellpadding=0 cellspacing=0 width=100% style="border-collapse: collapse">
<tr>
<th>序号</th>
<th>姓名</th>
<th>编号</th>
<th>个人识别码</th>
<th>身份证</th>
</tr>
<?php foreach ($OutputExcel as $key => $value): ?>
<tr>
<td>{$key+1}</td>
<td>{$value[‘stuff_nicname‘]}</td>
<td>{$value[‘stuff_number‘]}</td>
<td>{$value[‘stuff_code‘]}</td>
<td>{$value[‘stuff_idcard‘]}</td>
</tr>
<?php endforeach ?>
</table>