PHP简单导出Excel表格
<?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";
}
?>
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。