轻松实现PHP输出excel
要将PHP数据输出到excel表格上,PHP在这方面的支持非常好,PHP只需简单几句就可以输出一个简单的excel表。
PHP代码:
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:attachment;filename=users.xls" );
echo "公司名称"."\t";
echo "用户名"."\t";
echo "密码"."\t";
echo "二级域名"."\t";
echo "\n";
foreach($result['result'] as $val){
echo "$val->ComName"."\t";
echo "$val->UserName"."\t";
echo "$val->UserTruePw"."\t";
echo emptyempty($val->DoMainName)?'':('http://'.$val->DoMainName.'.jiaomai.com')."\t";
echo "\n";
}
?>