$list = $this->recommend($request); $data = array(); foreach($list as $k=>$v){ $data[] = array_values($v); $len = count($v); } $header = array('日期','卖方','推荐人','推荐码','状态'); array_unshift($data,$header); $filename = "推荐码"; $width = array('A'=>20,'B'=>20,'C'=>20,'D'=>30,'E'=>20); excel($data,$filename,$len,$width);
if (!function_exists('excel')){ /** * @desc 导出excel * @param $data 二维数组 * @param $filename 导出excel的名称 * @param $len 导出excel列的个数 * @param $arr 每一列的长度数组 */ function excel($data,$filename,$len,$width){ $filename = $filename.date('Y-m-d H:i:s',time()); $arr = array('A','B','C','D','E','F','G','H','I','J',