header("Content-type: application/vnd.ms-excel");
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=".$this->fileName."_".date(‘Y-m-d‘).".xls");
header(‘Expires:0‘);
header(‘Pragma:public‘);
echo $strTable;
其中$strTable是html的table标签的代码。基本格式如下:
$strTable = "<table>";
$strTable .= "<tr><th>项目1<th><th>项目2<th><tr>";
$strTable .= "<tr><td>张三<td><td>李四<td><tr>";
$strTable .= "<table>";