欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

phptable如何轉(zhuǎn)excel

php table轉(zhuǎn)excel的實現(xiàn)方法:首先定義一個“excelData”方法;然后設置表格數(shù)據(jù)、head以及表頭;最后通過“excelData($dataResult, $titlename, $headtitle...;”方式生成excel文件即可。

開福網(wǎng)站制作公司哪家好,找創(chuàng)新互聯(lián)!從網(wǎng)頁設計、網(wǎng)站建設、微信開發(fā)、APP開發(fā)、響應式網(wǎng)站建設等網(wǎng)站項目制作,到程序開發(fā),運營維護。創(chuàng)新互聯(lián)從2013年成立到現(xiàn)在10年的時間,我們擁有了豐富的建站經(jīng)驗和運維經(jīng)驗,來保證我們的工作的順利進行。專注于網(wǎng)站建設就選創(chuàng)新互聯(lián)

推薦:《PHP視頻教程》

php 根據(jù)html table生成excel文件

<?php

/*
*處理Excel導出
*@param $datas array 設置表格數(shù)據(jù)
*@param $titlename string 設置head
*@param $title string 設置表頭
*/
function excelData($datas, $titlename, $title, $filename) {
    $str = "<html xmlns:o=\\"urn:schemas-microsoft-com:office:office\\"\\r\\nxmlns:x=\\"urn:schemas-microsoft-com:office:excel\\"\\r\\nxmlns=\\"http://www.w3.org/TR/REC-html40\\">\\r\\n<head>\\r\\n<meta http-equiv=Content-Type content=\\"text/html; charset=utf-8\\">\\r\\n</head>\\r\\n<body>";
    $str .= "<table border=1><head>" . $titlename . "</head>";
    $str .= $title;
    foreach ($datas as $key => $rt) {
        $str .= "<tr>";
        foreach ($rt as $k => $v) {
            $str .= "<td>{$v}</td>";
        }
        $str .= "</tr>\\n";
    }
    $str .= "</table></body></html>";
    echo $str;
    header("Content-Type: application/vnd.ms-excel; name='excel'");
    header("Content-type: application/octet-stream");
    header("Content-Disposition: attachment; filename=" . $filename);
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Pragma: no-cache");
    header("Expires: 0");
    exit($str);
}


$dataResult = array(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11), array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11));
$headTitle = "XX保險公司 優(yōu)惠券贈送記錄";
$title = "優(yōu)惠券記錄";
$headtitle = "<tr style='height:50px;border-style:none;><th border=\\"0\\" style='height:60px;width:270px;font-size:22px;' colspan='11' >{$headTitle}</th></tr>";
$titlename = "<tr>
               <th style='width:70px;' >合作商戶</th>
               <th style='width:70px;' >會員卡號</th>
               <th style='width:70px;'>車主姓名</th>
               <th style='width:150px;'>手機號</th>
               <th style='width:70px;'>車牌號</th>
               <th style='width:100px;'>優(yōu)惠券類型</th>
               <th style='width:70px;'>優(yōu)惠券名稱</th>
               <th style='width:70px;'>優(yōu)惠券面值</th>
               <th style='width:70px;'>優(yōu)惠券數(shù)量</th>
               <th style='width:70px;'>贈送時間</th>
               <th style='width:90px;'>截至有效期</th>
           </tr>";
$filename = $title . ".xls";
excelData($dataResult, $titlename, $headtitle, $filename);
echo 'success';

文章名稱:phptable如何轉(zhuǎn)excel
文章轉(zhuǎn)載:http://chinadenli.net/article24/chdeje.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供定制網(wǎng)站網(wǎng)站維護網(wǎng)站收錄網(wǎng)站設計公司標簽優(yōu)化自適應網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都app開發(fā)公司