Require_once '.. /classes/phpexcel.php '; Require_once '.. /classes/phpexcel/iofactory.php '; $objPHPExcel = new Phpexcel (); $objPHPExcel->getproperties ()->setcreator ("Maarten Balliauw")->setlastmodifiedby ("Maarten Balliauw")- >settitle ("Office 2007 XLSX Test Document")->setsubject ("Office 2007 XLSX Test Document")->setdescription (" Document for Office 2007 XLSX, generated using PHP classes. ") ->setkeywords ("Office 2007 OPENXML PHP")->setcategory ("Test result file"); $objPHPExcel->setactivesheetindex (0); $objRichText = new Phpexcel_richtext (); $objRichText->createtext ("); $objPayable = $objRichText->createtextrun (' immediate monitoring data '); $objPayable->getfont ()->setcolor (new Phpexcel_style_color (phpexcel_style_color::color_red)); $objPayable->getfont ()->setbold (true); $objPayable->getfont ()->setsize (24); $objPHPExcel->getactivesheet ()->getcell (' B1 ')->setvalue ($objRichText); $objPHPExcel->getactivesheet ()->getstyle (' B1 ')->getfont ()->setbold (true); Bold $objPHPExcel->getactivesheet ()->getstyle (' B1 ')->getfont ()->setsize (24); Font size $objPHPExcel->getactivesheet ()->getstyle (' B1 ')->getfont ()->getcolor () ()->setargb (phpexcel_style_ color::color_red); Text color $objPHPExcel->getactivesheet ()->getstyle (' A1:g1 ')->getfill ()->setfilltype (Phpexcel_style_fill:: Fill_solid); $objPHPExcel->getactivesheet ()->getstyle (' A1:g1 ')->getfill ()->getstartcolor () (" 00ffffe3 ');/shading Width $objPHPExcel->getactivesheet ()->getcolumndimension (' A ')->setautosize (true); $objPHPExcel->getactivesheet ()->getcolumndimension (' A ')->setwidth (12); $objPHPExcel->getactivesheet ()->getcolumndimension (' B ')->setwidth (18); $objPHPExcel->getactivesheet ()->getcolumndimension (' C ')->setwidth (12); $objPHPExcel->getactivesheet ()->getcolumndimension (' D ')->setwidth (18); $objPHPExcel->getactivesheet ()->getcolumndimension (' E ')->setwidth (12); $objPHPExcel->getactivesheet ()->getcolumndimension (' F ')->setwidth (18); $objPHPExcel->getactivesheet ()->getcolumndimension (' G ')->setwidth (20); Row height for ($i = 2; $i <= $i + +) { $objPHPExcel->getactivesheet ()->getrowdimension ($i)->setrowheight (22); } $objPHPExcel->getactivesheet ()->setcellvalue (' A2 ', ' name '); $objPHPExcel->getactivesheet ()->setcellvalue (' A3 ', ' PHP '); $objPHPExcel->getactivesheet ()->setcellvalue (' A4 ', ' EXCEL '); $objPHPExcel->getactivesheet ()->setcellvalue (' A5 ', '); $objPHPExcel->getactivesheet ()->setcellvalue (' A6 ', ' XXX '); $objPHPExcel->getactivesheet ()->setcellvalue (' A7 ', ' V '); $objPHPExcel->getactivesheet ()->setcellvalue (' A8 ', ' d '); $objPHPExcel->getactivesheet ()->setcellvalue (' A9 ', ' name '); $objPHPExcel->getactivesheet ()->setcellvalue (' A10 ', ' description '); for ($i = 2; $i <= $i + +) { $objPHPExcel->getactivesheet ()->getstyle (' A '. $i)->getfont ()-&G T;setbold (true); //Bold } $objPHPExcel->getactivesheet ()->setcellvalue (' B2 ', ' [name] '); $objPHPExcel->getactivesheet ()->setcellvalue (' B3 ', ' exporting Excel with pictures '); $objPHPExcel->getactivesheet ()->setcellvalue (' B4 ', ' XXXXX '); Add a picture to Excel $objDrawing = new phpexcel_worksheet_drawing (); $objDrawing->setname (' Photo '); $objDrawing->setdescription (' Photo '); $objDrawing->setpath ('.. /images/touxiang.jpg '); $objDrawing->setheight (170); $objDrawing->setwidth (120); $objDrawing->setcoordinates (' G2 '); $objDrawing->setworksheet ($objPHPExcel->getactivesheet ()); $objPHPExcel->getactivesheet ()->setcellvalue (' A17 ', ' other requirements '); $objPHPExcel->getactivesheet ()->setcellvalue (' B17 ', ' [other requirements] '); $objPHPExcel->getactivesheet ()->getstyle (' A17 ')->getfont ()->setbold (true); Bold $objPHPExcel->setactivesheetindex (0); $objPHPExcel->getactivesheet ()->settitle (' immediate monitoring data '); $objWriter = Phpexcel_iofactory::createwriter ($objPHPExcel, ' Excel5 '); $objWriter->save (' Phpexcel.xls '); |