国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > PHP > 正文

php使用phpword生成word文檔

2020-03-22 18:53:29
字體:
來源:轉載
供稿:網友
php使用phpword生成word文檔 :

相關推薦:PHPWord中文使用手冊下載

<p><?phprequire_once '../libs/PHPWord/PHPWord.php';require_once '../libs/PHPWord/PHPWord/IOFactory.php';require_once '../../config.php';// require_once '../common/conn.php';</p><p>// New Word Document$PHPWord = new PHPWord();</p><p>/**********文本格式的word text.php************/// New portrait section</p><p>//逗號 分割字符串$arr = $_REQUEST['arr'];$a = explode(',',$arr);//echo $arr;date_default_timezone_set("Asia/Shanghai");//設置一個時區$tm=date('Y-m-d H:i:s');//exit($tm);/**********前多日雨量*********/if(in_array('1', $a, TRUE)){$section = $PHPWord->createSection();$PHPWord->addFontStyle('rStyle', array('bold'=>false, 'italic'=>false, 'size'=>16));$PHPWord->addParagraphStyle('pStyle', array('align'=>'center', 'spaceAfter'=>100));$c = "前三日雨量報表";$section->addText($c, 'rStyle', 'pStyle');</p><p>$styleTable = array('borderSize'=>6, 'borderColor'=>'006699', 'cellMargin'=>80);$styleFirstRow = array('borderBottomSize'=>18, 'borderBottomColor'=>'0000FF', 'bgColor'=>'66BBFF');</p><p>// Define cell style arrays$styleCell = array('valign'=>'center');// Define font style for first row$fontStyle = array('bold'=>true, 'align'=>'center');//設置標題$PHPWord->addFontStyle('rStyle', array('bold'=>true, 'italic'=>true, 'size'=>16));$PHPWord->addParagraphStyle('pStyle', array('align'=>'center', 'spaceAfter'=>100));</p><p>// Add table style$PHPWord->addTableStyle('myOwnTableStyle', $styleTable, $styleFirstRow);</p><p>// Add table$table = $section->addTable('myOwnTableStyle');</p><p>// Add row設置行高$table->addRow(500);</p><p>$table->addCell(2300, $styleCell)->addText('站碼', $fontStyle);$table->addCell(2300, $styleCell)->addText('站名', $fontStyle);$table->addCell(2300, $styleCell)->addText('雨量', $fontStyle);$table->addCell(2300, $styleCell)->addText('水文站監測類型', $fontStyle);</p><p>$conn = mssql_connect($config['mssql']['host'],$config['mssql']['user'],$config['mssql']['password']);mssql_select_db($config['mssql']['dbname'],$conn);</p><p>$stm = date('Y-m-d H:i:s',strtotime('-3 days'));$sql = "EXEC HNOW05_GETPPSPACE '','','".$stm."',1,1";$res=mssql_query($sql);</p><p>while($arr = mssql_fetch_array($res)){//echo $arr["STCD"]."</br>";$table->addRow();$table->addCell(2300)->addText($arr["STCD"]);$table->addCell(2300)->addText($arr["STNM"]);$table->addCell(2300)->addText($arr["P"]);if($arr["STTP"] == 'MM'){$table->addCell(2300)->addText('氣象站');}else if($arr["STTP"] == 'BB'){$table->addCell(2300)->addText('蒸發站');}else if($arr["STTP"] == 'DD'){$table->addCell(2300)->addText('堰閘水文站');}else if($arr["STTP"] == 'TT'){$table->addCell(2300)->addText('落潮位站');}else if($arr["STTP"] == 'DP'){$table->addCell(2300)->addText('泵站');}else if($arr["STTP"] == 'SS'){$table->addCell(2300)->addText('墑情站');}else if($arr["STTP"] == 'PP'){$table->addCell(2300)->addText('雨量站');}else if($arr["STTP"] == 'ZZ'){$table->addCell(2300)->addText('河道水位水文站');}else if($arr["STTP"] == 'RR'){$table->addCell(2300)->addText('水庫水文站');}else if($arr["STTP"] == 'ZG'){$table->addCell(2300)->addText('地下水站');}else if($arr["STTP"] == 'ZB'){$table->addCell(2300)->addText('分洪水位站');}}$section->addTextBreak(2);}else{</p><p>}</p><p>/******地質災害*******/if(in_array('3', $a, TRUE)){$section = $PHPWord->createSection();$PHPWord->addFontStyle('rStyle', array('bold'=>false, 'italic'=>false, 'size'=>16));$PHPWord->addParagraphStyle('pStyle', array('align'=>'center', 'spaceAfter'=>100));$c = "地質災害";$section->addText($c, 'rStyle', 'pStyle');</p><p>$content="根據市氣象局未來24小時降雨預報和市水利局實時降雨數據,市國土資源局進行了地質災害預報,請有關部門關注</p><p>實時預警信息,做好地質災害防范工作";$section->addText($content);// Add image elements$section->addImage("images/image001.jpg", array('width'=>600, 'height'=>480, 'align'=>'center'));}else{</p><p>}// Save File$fileName = "word報表".date("YmdHis");header("Content-type: application/vnd.ms-word");header("Content-Disposition:attachment;filename=".$fileName.".docx");header('Cache-Control: max-age=0');$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');$objWriter->save('php://output');?></p>

以上就是php使用phpword生成word文檔 的內容,更多相關內容請關注PHP (www.survivalescaperooms.com)!

相關文章:

php導出生成word的方法

在php程序中將網頁生成word文檔并提供下載的實例代碼

PHP生成word文檔的三種實現方式

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 喀喇沁旗| 家居| 寿宁县| 商南县| 潮安县| 安达市| 牡丹江市| 和平县| 安阳县| 深州市| 获嘉县| 南城县| 德昌县| 礼泉县| 阜康市| 西盟| 荃湾区| 西城区| 宝山区| 岗巴县| 合江县| 凤台县| 抚宁县| 惠来县| 石景山区| 綦江县| 南和县| 新平| 平陆县| 沛县| 宜兰县| 沅江市| 都安| 绥宁县| 化隆| 台北市| 延吉市| 龙门县| 河津市| 邵东县| 九龙城区|