| 以下是代码片段: <?php header(“Content-type:application/vnd.ms-excel”); header(“Content-Disposition:attachment;filename=test_data.xls”); $tx=’表头’; echo $tx.”\n\n”; //输出内容如下: echo “姓名”.”\t”; echo “年龄”.”\t”; echo “学历”.”\t”; echo “\n”; echo “张三”.”\t”; echo “25″.”\t”; echo “本科”.”\t”; for($i=1;$i<10;$i++) { echo “\n”; echo “张三”.”\t”; echo “25″.”\t”; echo “本科”.”\t”; } ?> |
for循环里面的数据可以调整为数据库中的数据。这是最简便的一种方式。