<?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 "\t"; echo iconv("UTF-8", "GBK", "支付時間") ;echo "\t"; foreach($list as $key => $val) { echo "\r\n"; echo iconv("UTF-8", "GBK", "".date("Y-m-d H:i:s", $val['add_time'])); echo "\t"; echo iconv("UTF-8", "GBK", "".date("Y-m-d H:i:s", $val['pay_time'])); echo "\t"; }
須要注意一個坑, 當輸入的數字過長的時候excel會自動截取變掉這個數據,輸出的時候要把過長的數據加雙引號變成字符串才能夠避免這個問題php