<?php header("Content-type:application/vnd.ms-excel"); header("Content-Disposition:attachment;filename=打钱记录.xls"); header("Content-Transfer-Encoding:binary"); echo iconv("UTF-8", "GBK", "申请时间"); echo " "; echo iconv("UTF-8", "GBK", "支付时间") ;echo " "; foreach($list as $key => $val) { echo " "; echo iconv("UTF-8", "GBK", "".date("Y-m-d H:i:s", $val['add_time'])); echo " "; echo iconv("UTF-8", "GBK", "".date("Y-m-d H:i:s", $val['pay_time'])); echo " "; }
需要注意一个坑, 当输入的数字过长的时候excel会自动截取变掉这个数据,输出的时候要把过长的数据加双引号变成字符串才可以避免这个问题