Require_once '../libs/PHPWord. php ';
- Require_once '../libs/PHPWord/IOFactory. php ';
- Require_once '.../../config. php ';
- // Require_once '../common/conn. php ';
// New Word Document
- $ PHPWord = new PHPWord ();
/*********** Word text. php ************/
- // New portrait section
// Comma-separated string
- $ Arr = $ _ REQUEST ['arr'];
- $ A = explode (',', $ arr );
- // Echo $ arr;
- Date_default_timezone_set ("Asia/Shanghai"); // you can specify a time zone.
- $ Tm = date ('Y-m-d H: I: s ');
- // Exit ($ tm );
- /************ Rainfall of the previous multiple days *********/
- 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', 'space' => 100 ));
- $ C = "rainfall report for the first three days ";
- $ Section-> addText ($ c, 'rstyle', 'pstyle ');
$ StyleTable = array ('bordersize' => 6, 'bordercolor' => '123', '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 ');
- // Set the title
- $ PHPWord-> addFontStyle ('rstyle', array ('bold '=> true, 'italic' => true, 'size' => 16 ));
- $ PHPWord-> addParagraphStyle ('pstyle', array ('align '=> 'center', 'space' => 100 ));
// Add table style
- $ PHPWord-> addTableStyle ('myowntablestyle', $ styleTable, $ styleFirstRow );
// Add table
- $ Table = $ section-> addTable ('myowntablestyle ');
// Add row to set the row height
- $ Table-> addRow (500 );
$ Table-> addCell (2300, $ styleCell)-> addText ('site code', $ fontStyle );
- $ Table-> addCell (2300, $ styleCell)-> addText ('site name', $ fontStyle );
- $ Table-> addCell (2300, $ styleCell)-> addText ('rainfall ', $ fontStyle );
- $ Table-> addCell (2300, $ styleCell)-> addText ('hydrological station monitoring type', $ fontStyle );
$ Conn = mssql_connect ($ config ['mssql'] ['host'], $ config ['mssql'] ['user'], $ config ['SQL'] ['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 ('weather station ');
- } Else if ($ arr ["STTP"] = 'BB '){
- $ Table-> addCell (2300)-> addText ('Evaporation site ');
- } Else if ($ arr ["STTP"] = 'DD '){
- $ Table-> addCell (2300)-> addText ('dayu hydrological station ');
- } Else if ($ arr ["STTP"] = 'TT '){
- $ Table-> addCell (2300)-> addText ('tidal slots ');
- } Else if ($ arr ["STTP"] = 'DP '){
- $ Table-> addCell (2300)-> addText ('pumping station ');
- } Else if ($ arr ["STTP"] = 'SS '){
- $ Table-> addCell (2300)-> addText ('Site of moisture ');
- } Else if ($ arr ["STTP"] = 'pp '){
- $ Table-> addCell (2300)-> addText ('Rain station ');
- } Else if ($ arr ["STTP"] = 'zz '){
- $ Table-> addCell (2300)-> addText ('River water level and hydrological station ');
- } Else if ($ arr ["STTP"] = 'rr '){
- $ Table-> addCell (2300)-> addText ('Reservoir hydrological station ');
- } Else if ($ arr ["STTP"] = 'zg '){
- $ Table-> addCell (2300)-> addText ('Groundwater station ');
- } Else if ($ arr ["STTP"] = 'zb '){
- $ Table-> addCell (2300)-> addText ('flood location site ');
- }
- }
- $ Section-> addTextBreak (2 );
- } Else {
}
/******* Geological disasters *******/
- 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', 'space' => 100 ));
- $ C = "geological disasters ";
- $ Section-> addText ($ c, 'rstyle', 'pstyle ');
$ Content = "according to the rainfall forecast of the municipal meteorological administration and the real-time rainfall data of the municipal water conservancy bureau in the next 24 hours, the Municipal Bureau of Land and Resources has made a geological disaster forecast. please pay attention to it.
Real-time warning information to prevent geological disasters ";
- $ Section-> addText ($ content );
- // Add image elements
- $ Section-> addImage ("images/image001.jpg", array ('width' => 600, 'height' => 480, 'align '=> 'center '));
- } Else {
}
- // Save File
- $ FileName = "word Report". 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 ');
- ?>
|