nowphp

导航

 
/*
 * 通过数组遍历得出导出报表类型结构
 * @pre 表头 array()  $list要导出的数据
 */
    function getXLSFromList($pres,$lists){
        $keys=array_keys($pres);
        $content="";
        $content.="<table border='1'><tr>";
        foreach($pres as $_pre){
            $content.="<td>$_pre</td>";
        }
        $content.="</tr>";
        foreach($lists as $_list){
            $content.= "<tr>";
            foreach($keys as $key){
                $content.= "<td>".$_list[$key]."</td>";
            }
            $content.="</tr>";
        }
        $content.="</table>";
        return $content;
    }
header("Content-type:application/vnd.ms-execl;charset=gb2312");
header("Content-Disposition:attactment;filename=dowload.xls");
header("Pragma: no-cache");
header("Expires: 0");
echo $content;
exit;

  

 
 

 

posted on 2018-01-11 20:03  不断成长  阅读(105)  评论(0编辑  收藏  举报