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');$styletable = array('bordersize'=>6, 'bordercolor'=>'006699', 'cellmargin'=>80);
$stylefirstrow = array('borderbottomsize'=>18, 'borderbottomcolor'=>'0000ff', 'bgcolor'=>'66bbff');// 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));// add table style
$phpword->addtablestyle('myowntablestyle', $styletable, $stylefirstrow);// add table
$table = $section->addtable('myowntablestyle');// add row设置行高
$table->addrow(500);$table->addcell(2300, $stylecell)->addtext('站码', $fontstyle);
$table->addcell(2300, $stylecell)->addtext('站名', $fontstyle);$table->addcell(2300, $stylecell)->addtext('雨量', $fontstyle);$table->addcell(2300, $stylecell)->addtext('水文站监测类型', $fontstyle);$conn = mssql_connect($config['mssql']['host'],$config['mssql']['user'],$config['mssql']['password']);
mssql_select_db($config['mssql']['dbname'],$conn);$stm = date('y-m-d h:i:s',strtotime('-3 days'));
$sql = exec hnow05_getppspace '','','.$stm.',1,1;$res=mssql_query($sql);while($arr = mssql_fetch_array($res)){
//echo $arr[stcd].;$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{}
/******地质灾害*******/
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');$content=根据市气象局未来24小时降雨预报和市水利局实时降雨数据,市国土资源局进行了地质灾害预报,请有关部门关注
实时预警信息,做好地质灾害防范工作;
$section->addtext($content);// add image elements$section->addimage(images/image001.jpg, array('width'=>600, 'height'=>480, 'align'=>'center'));}else{}
// 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');?>
复制代码