PHP將HTML的內容儲存成word文檔

來源:互聯網
上載者:User

標籤:家庭   xxx   ice   office   ble   單位   lsp   flush   ati   

<?php class word{    function start()    {        ob_start();        echo ‘<html xmlns:o="urn:schemas-microsoft-com:office:office"  xmlns:w="urn:schemas-microsoft-com:office:word"  xmlns="http://www.w3.org/TR/REC-html40">              <head>                   <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>                   <xml><w:WordDocument><w:View>Print</w:View></xml>            </head><body>‘;    }    function save($path)    {        echo "</body></html>";        $data = ob_get_contents();        ob_end_clean();        $this->wirtefile ($path,$data);    }    function wirtefile ($fn,$data)    {        $fp=fopen($fn,"wb");        fwrite($fp,$data);        fclose($fp);    }}/*產生doc檔案*/$html = ‘<style>.onle_bm{ width:50%; line-height:50px; font-size:24px; text-align:center; color:#000;margin: 0px auto;}.onle_bts{ width:50%; line-height:30px; font-size:16px; color:#666; margin:0px auto;}.onle_bd{ width:50%; margin:0px auto; padding-top:20px;}.onle_bd table{ border-right: 1px solid #000;  border-bottom: 1px solid #000;height: 40px;}.onle_bd td{font-size: 14px; color: #000; border-left: 1px solid #000;  border-top: 1px solid #000;height: 40px;}</style><div class="onle_bm">國家登記表</div><div class="onle_bts">報名序號:<span>20170001</span></div><div class="onle_bd"><form action="" method="get"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr>   <td width="14%" align="center"><p >報考崗位</p></td>   <td width="34%"><label for="textfield"><p>‘.$_POST[‘bkgw‘].‘</p></label>     </td>   <td width="11%" align="center"><p >專業類別</p></td>   <td colspan="2">‘.$_POST[‘sxzy‘].‘</td>   <td width="18%" rowspan="4"><img src="https://img6.bdstatic.com/img/image/smallpic/t2.jpg" width="100px" height="100px" /></td> </tr> <tr>   <td align="center"><p >姓名 </p></td>   <td><p>‘.$_POST[‘username‘].‘</p></td>   <td align="center"><p >出生年月</p></td>   <td colspan="2" align="center"><p >‘.$_POST[‘csmy‘].‘</p></td>   </tr> <tr>   <td align="center"><p >戶口所在地</p></td>   <td><p >‘.$_POST[‘hjaddress‘].‘</p></td>   <td align="center"><p >性別</p></td>   <td colspan="2" align="center"><p >‘.$_POST[‘sex‘].‘</p></td>   </tr> <tr>   <td align="center"><p >政治面貌</p></td>   <td align="center"><p >‘.$_POST[‘zzmm‘].‘</p></td>   <td align="center"><p >婚姻狀況</p></td>   <td colspan="2" align="center"><p >‘.$_POST[‘hyzk‘].‘</p></td>   </tr> <tr>   <td align="center"><p >最高學曆 </p></td>   <td align="center"><p >‘.$_POST[‘zgxl‘].‘</p></td>   <td align="center"><p >畢業證號</p></td>   <td width="11%" align="center"><p>‘.$_POST[‘byzh‘].‘</p></td>   <td width="12%" align="center"><p >學位</p></td>   <td align="center"><p >‘.$_POST[‘degree‘].‘</p></td> </tr> <tr>   <td align="center"><p >畢業院校 </p></td>   <td colspan="3"><p>‘.$_POST[‘byyx‘].‘</p></td>   <td align="center"><p >所學專業</p></td>   <td align="center"><p >‘.$_POST[‘sxzy‘].‘</p></td> </tr> <tr>   <td align="center"><p >現工作單位</p></td>   <td colspan="3"><p>‘.$_POST[‘xgzdw‘].‘</p></td>   <td align="center"><p >曾擔任職務 </p></td>   <td align="center"><p >‘.$_POST[‘cdrzw‘].‘</p></td> </tr> <tr>   <td align="center"><p >郵寄地址</p></td>   <td colspan="3"><p>‘.$_POST[‘txaddress‘].‘</p></td>   <td align="center"><p >郵遞區號</p></td>   <td align="center"><p >‘.$_POST[‘yzbm‘].‘</p></td> </tr> <tr>   <td align="center"><p >現居住地</p></td>   <td colspan="3">‘.$_POST[‘xjzaddress‘].‘</td>   <td align="center"><p >行動電話</p></td>   <td align="center"><p>‘.$_POST[‘ydphone‘].‘</p></td> </tr> <tr>   <td align="center"><p >社會安全號碼</p></td>   <td><p>‘.$_POST[‘idcard‘].‘</p></td>   <td align="center"><p >電子郵箱</p></td>   <td colspan="3"><p>‘.$_POST[‘email‘].‘</p></td>   </tr> <tr>   <td align="center"><p >掌握何種外語及程度</p></td>   <td align="center"><p >‘.$_POST[‘zwwycd‘].‘</p></td>   <td align="center"><p >電腦掌握程度</p></td>   <td align="center"><p >‘.$_POST[‘jsjzwcd‘].‘</p></td>   <td align="center"><p >有無刑事記錄</p></td>   <td align="center"><p >‘.$_POST[‘xsfzjl‘].‘</p></td>   </tr> <tr>   <td align="center"><p >畢業年份</p></td>   <td align="center"><p >‘.$_POST[‘bynf‘].‘</p></td>   <td colspan="3" align="center"><p >直系親屬是否從事商標代理</p></td>   <td align="center"><p >‘.$_POST[‘zxqscssbdl‘].‘</p></td> </tr> <tr>   <td align="center"><p >學習經曆 </p></td>   <td colspan="5"><label for="textarea"></label><p>    ‘.$_POST[‘xxjsxjl‘].‘</p></td>   </tr> <tr>   <td align="center"><p >工作經曆 </p></td>   <td colspan="5"><p>‘.$_POST[‘gzjl‘].‘</p></td>   </tr> <tr>   <td align="center"><p >獎懲情況</p></td>   <td colspan="5"><p>‘.$_POST[‘jcqk‘].‘</p></td>   </tr> <tr>   <td rowspan="2" align="center"><p align="center" >家庭成員和 <br />     主要社會 <br />     關係 </p></td>   <td align="center"><p >姓名 </p></td>   <td align="center"><p >關係 </p></td>   <td colspan="2" align="center"><p >所在單位職務 </p></td>   <td align="center"><p >政治面貌 </p></td> </tr> <tr>   <td colspan="5"></td>   </tr> <tr>   <td align="center"><p >備忘</p></td>   <td colspan="5">‘.$_POST[‘bz‘].‘</td>   </tr></table></form></div><div class="onle_bts">註:最高學曆為國家承認的學曆</div>‘;$html = file_get_contents("http://www.xxxx.com/test.html");// echo $html;exit;$word = new word();$word->start();$wordname = ‘word/test.doc‘;//組建檔案路徑echo $html;$word->save($wordname);ob_flush();//每次執行前重新整理緩衝flush();/*產生doc檔案 end*/

 

  

PHP將HTML的內容儲存成word文檔

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.