php生成word并下载
生活随笔
收集整理的這篇文章主要介紹了
php生成word并下载
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
1.前端代碼:? ?index.html
<!DOCTYPE html> <html> <head><title>PHP生成Word文檔</title><meta charset="utf-8"> </head> <body><h1 style="text-align: center">xxx的簡歷</h1> <h3>編號:000001</h3> <table border="1" cellpadding="3" cellspacing="0" > <tr > <td width="93" valign="center" colspan="2" >姓名</td> <td width="160" valign="center" colspan="4" >xxx</td> <td width="89" valign="center" colspan="2" >學(xué)歷</td> <td width="156" valign="center" colspan="3" >xxx</td> <td width="125" colspan="2" rowspan="4" align="center" valign="middle" ><img src="./img.jpg" width="120" height="120" /></td> </tr> <tr > <td width="93" valign="center" colspan="2" >性別</td> <td width="72" valign="center" colspan="2" >xxx</td> <td width="88" valign="center" colspan="2" >出生年月</td> <td width="89" valign="center" colspan="2" >xxx</td> <td width="68" valign="center" >戶籍地</td> <td width="87" valign="center" colspan="2" >xxx</td> </tr> <tr > <td width="93" valign="center" colspan="2" >身高</td> <td width="72" valign="center" colspan="2" >xxxcm</td> <td width="88" valign="center" colspan="2" >體重</td> <td width="89" valign="center" colspan="2" >xxxkg</td> <td width="68" valign="center" >婚姻狀況</td> <td width="87" valign="center" colspan="2" >xxx</td> </tr> <tr > <td width="93" valign="center" colspan="2" >手機</td> <td width="160" valign="center" colspan="4" >xxx</td> <td width="89" valign="center" colspan="2" >Email</td> <td width="156" valign="center" colspan="3" >xxx</td> </tr> <tr > <td width="93" valign="center" colspan="2" style="width:93px;">家庭住址</td> <td width="530" valign="center" colspan="11" >xxx</td> </tr> <tr > <td width="93" valign="center" colspan="2" rowspan="3">求職意向</td> <td width="93" valign="center" colspan="2">希望從事職業(yè)</td> <td width="200" valign="center" colspan="2">xxx</td> <td width="93" valign="center" colspan="2">希望薪資</td> <td width="200" valign="center" colspan="5">xxx元/月</td> </tr> <tr> <td width="93" valign="center" colspan="2" >希望工作地區(qū)</td> <td width="200" valign="center" colspan="2" >xxx</td> <td width="93" valign="center" colspan="2" >食宿要求</td> <td width="200" valign="center" colspan="5" >xxx</td> </tr> <tr> <td width="93" valign="center" colspan="2" >目前狀況</td> <td width="200" valign="center" colspan="9" >xxx</td> </tr> <tr> <td width="93" valign="center" style="color: red">自我評價</td> <td width="570" valign="center" colspan="12" >xxx</td> </tr> <tr> <td width="93" valign="center" >工作經(jīng)歷</td> <td width="570" valign="center" colspan="12" >xxx</td> </tr> <tr> <td width="93" valign="center" >教育經(jīng)歷</td> <td width="570" valign="center" colspan="12" >xxx</td> </tr> <tr> <td width="93" valign="center" >培訓(xùn)經(jīng)歷</td> <td width="570" valign="center" colspan="12" >xxx</td> </tr> </table> <p><a href="./index.php" rel="external nofollow" >點擊下載</a></p></body> </html>后端代碼:index.php
<?php //獲取1.html文檔的內(nèi)容(包括html代碼) $result = file_get_contents('./index.html'); echo "$result"; // /保存/// //打開緩沖區(qū) ob_start(); header("Cache-Control: public"); Header("Content-type: application/octet-stream"); Header("Accept-Ranges: bytes"); //判斷瀏覽器類型 if (strpos($_SERVER["HTTP_USER_AGENT"],'MSIE')) { header('Content-Disposition: attachment; filename=test.doc'); }else if (strpos($_SERVER["HTTP_USER_AGENT"],'Firefox')) { Header('Content-Disposition: attachment; filename=test.doc'); } else { header('Content-Disposition: attachment; filename=test.doc'); } //不使用緩存 header("Pragma:no-cache"); //過期時間 header("Expires:0"); //輸出全部內(nèi)容到瀏覽器 ob_end_flush(); ?>?
轉(zhuǎn)載于:https://www.cnblogs.com/afeige/p/10877412.html
總結(jié)
以上是生活随笔為你收集整理的php生成word并下载的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 理性分析PDD,技术BUG?市场误操?还
- 下一篇: Hdu--3966(树链剖分,线段树 o