header ('Content-type: application/x-msexcel');
header ("Content-Disposition: attachment; filename=$filename");
header("Pragma: no-cache");
header("Expires: 0");
echo '<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="expires" content="Mon, 06 Jan 1999 00:00:01 GMT">
<meta http-equiv=Content-Type content="text/html; charset=gb2312">
<!--[if gte mso 9]><xml>
<x:ExcelWorkbook>
<x:ExcelWorksheets>
<x:ExcelWorksheet>
<x:Name></x:Name>
<x:WorksheetOptions>
<x:DisplayGridlines/>
</x:WorksheetOptions>
</x:ExcelWorksheet>
</x:ExcelWorksheets>
</x:ExcelWorkbook>
</xml><![endif]-->
</head>';
echo '<table><tr>';
echo "<td>客户姓名</td>";
echo "<td>客户手机</td>";
echo "<td>身份证号</td>";
echo "<td>客户地址</td>";
echo "<td>申请银行</td>";
echo "<td>额度</td>";
echo '</tr>';
$result=$db->query($sql);
$num=$db->num_row($result);
if ($num==0)
{
echo "真遗憾,没有相符合条件的数据!";
exit;
}
while($rows=$db->fetch($result))
{
echo '<tr>';
echo '<td style="vnd.ms-excel.numberformat:@">'.$rows['name']."</td>";
echo '<td style="vnd.ms-excel.numberformat:@">'.$rows['phone']."</td>";
echo '<td style="vnd.ms-excel.numberformat:@">'.$rows['card']."</td>";
echo '<td style="vnd.ms-excel.numberformat:@">'.$rows['address']."</td>";
echo '<td style="vnd.ms-excel.numberformat:@">'.$rows['bank']."</td>";
echo '<td style="vnd.ms-excel.numberformat:@">'.$rows['quota']."</td>";
echo '</tr>';
}
echo '</table>';
本文档使用 521Wiki 发布