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();

 

版权声明:
作者:ForDream
链接:https://ishoud.com/index.php/2021/05/27/95.html
来源:工具人
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
海报
php导出xls
$strTable = '<table><tr style="text-align:center;"><td>姓名</td><td>手机号</td><td>节目</td><td&g……
<<上一篇
下一篇>>
文章目录
关闭
目 录