php导出xls

$strTable = '<table><tr style="text-align:center;"><td>姓名</td><td>手机号</td><td>节目</td><td>排名</td><td>票数</td></tr>';
            foreach($card_list as $k=>$v){
                $k++;
                $strTable .= '<tr style="text-align:center;">';
              
                $strTable .= '<td >'.$v['truename'].'</td>';
                $strTable .= '<td >'.$v['mobile'].'</td>';
                $strTable .= '<td >'.$v['item'].'</td>';
                $strTable .= '<td >'.$k.'</td>';
                $strTable .= '<td >'.$v['vote_num'].'</td>';
             
            }
            
            $strTable .='</table>';
            $excelname = '1234';
            //excel表格名  对中文转码
            $filename = iconv("utf-8", "GB2312", $excelname);
            //导出表格  strTable表格内容   filename表格名
            header("Content-type: application/vnd.ms-excel");
            header("Content-Type: application/force-download");
            header('Content-Disposition: attachment;filename="'.$excelname.'.xls"');
            header('Expires:0');
            header('Pragma:public');
            echo '<html><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'.$strTable.'</html>';
            exit();

 

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片快捷回复

    暂无评论内容