php导出excel

<?php
header ( "Content-type:application/vnd.ms-excel" );
header ( "Content-Disposition:filename=registration list.xls");
?>
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
<title>无标题文档</title>
<style>
td{
	text-align:center;
	font-size:12px;
	font-family:Arial, Helvetica, sans-serif;
	border:#1C7A80 1px solid;
	color:#152122;
	width:100px;
}
table,tr{
	border-style:none;
}
.title{
	background:#7DDCF0;
	color:#FFFFFF;
	font-weight:bold;
}
</style>
</head>

<body>
<table width='800' border='1'>
  <tr>
  	<td class='title'>报名ID</td>
    <td class='title'>姓名</td>
    <td class='title'>UID</td>
    <td class='title'>学号</td>
    <td class='title'>昵称</td>
    <?php if($type>=1){?>
    <td class='title'>职位</td>
    <?php }?>
    <td class='title'>单位</td>
    <td class='title'>手机</td>
    <td class='title'>QQ</td>
    <td class='title'>报名时间</td>
    <td class='title'>付款方式</td>
	 <?php if($type>=4){?>
    <td class='title'>报名级别</td>
	<?php }?>
	<?php if($type>=5){?>
    <td class='title'>最高学历</td>
	<td class='title'>意向类型</td>
	<td class='title'>意向专业</td>
	<?php }?>
  </tr>
  <?php foreach($list as $r): ?>
  <tr>
  	<td><?php echo $r['bmid']?></td>
    <td><?php echo $r['name']?></td>
    <td><?php echo $r['uid']?></td>
    <td><?php echo $r['studentid']?></td>
    <td><?php echo $r['nickname']?></td>
    <?php if($type>=1){?>
    <td><?php echo $r['position']?></td>
    <?php }?>
    <td><?php echo $r['company']?></td>
    <td><?php echo $r['mobile']?></td>
    <td><?php echo $r['qq']?></td>
    <td><?php echo date('Y-m-d H:i', $r['dateline'])?></td>
    <td><?php echo $r['pay']?></td>
	 <?php if($type>=4){?>
    <td><?php echo $r['level']?></td>
	<?php }?>
	 <?php if($type>=5){?>
    <td><?php echo $r['zuigaoxueli']?></td>
    <td><?php echo $r['yixiangleixing']?></td>
    <td><?php echo $r['yixiangzhuanye']?></td>        
	<?php }?>	
  </tr>
  <?php endforeach; ?>
</table>
</body>
</html>