php table如何轉換excel

PHPz
發布: 2023-03-05 22:52:02
原創
2706 人瀏覽過

php table轉excel的實作方法:先定義一個「excelData」方法;然後設定表格資料、head以及表頭;最後透過「excelData($dataResult, $titlename...;)」方式生成excel檔案即可。

php table如何轉換excel

推薦:《PHP影片教學

php 根據html table產生excel檔案

\r\n\r\n\r\n
\r\n"; $str .= "" . $titlename . "
"; $str .= $title; foreach ($datas as $key => $rt) { $str .= ""; foreach ($rt as $k => $v) { $str .= ""; } $str .= "\n"; } $str .= "
{$v}
"; 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保险公司 优惠券赠送记录"; $title = "优惠券记录"; $headtitle = "{$headTitle}"; $titlename = " 合作商户 会员卡号 车主姓名 手机号 车牌号 优惠券类型 优惠券名称 优惠券面值 优惠券数量 赠送时间 截至有效期 "; $filename = $title . ".xls"; excelData($dataResult, $titlename, $headtitle, $filename); echo 'success';
登入後複製

以上是php table如何轉換excel的詳細內容。更多資訊請關注PHP中文網其他相關文章!

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!