<?php
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment; filename=demo.xls');
header('Pragma: no-cache');
header('Expires: 0');
$title = array('編號', '姓名', '性別', '年齡', '身高', '體重');
$data = array(
array(1, '張三', '男', '22', 183, 72),
array(2, '李四', '女', '18', 170, 50),
array(3, '王五', '男', '14', 178, 68),
array(4, '趙六', '女', '34', 163, 48)
);
echo iconv('utf-8', 'gbk', implode("\t", $title)), "\n";
foreach ($data as $value) {
echo iconv('utf-8', 'gbk', implode("\t", $value)), "\n";
}
?>