php导出Excel

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
</head>

<?php
header("Content-type:   application/octet-stream");
header("Accept-Ranges:   bytes");
header("Content-type:application/vnd.ms-excel");   
header("Content-Disposition:attachment;filename=export_excel_gshjsl.xls");   

    echo "<body>";
    echo "   <div align='center'><font size='5'>1</font></div> ";
    echo "<table border='1' bordercolor='#999999' style='border-collapse: collapse'>";
    echo "<tr bgcolor='#f1f3f5'>" ;
    echo "    <td align='center'>2</td>" ;
    echo "    <td align='center'>3</td>"; 
    echo "    <td align='center'>4</td>" ;
    echo "    <td align='center'>5</td>" ;
    echo "    <td align='center'>6</td>" ;
    echo "    <td align='center'>7</td>";
   echo "    <td align='center'>8</td>" ;
   echo "</tr>";
   echo "</table>";
   echo "</body>";
?>
</html>
原文地址:https://www.cnblogs.com/wowchky/p/3051663.html