Feel the technical mastery of some too miscellaneous, a while to tinker with Java, a while to tinker PHP, while still engaged in. NET, maybe this just are life.
Before colleagues to a county legal committee do a set of stability information platform, the database is packaged MySQL, now customers want to export the data into a province of a set of platforms, preferably exported to Excel, online search for information is simply realized.
1. Download the Phpexcel class library, http://phpexcel.codeplex.com/, into the local lib/phpexcel
2. Follow the example implementation to export the Excel code as follows:
include_once'./lib/phpexcel/phpexcel.class.php '; include_once'./lib/phpexcel/phpexcel/iofactory.php '; $inputFileName= './dispute.xls '; $excel= Phpexcel_iofactory::load ($inputFileName); $excel->getproperties ()->setcreator ("Sxg") ->setlastmodifiedby ("Sxg") ->settitle ("Contradictory dispute export data") ->setsubject ("Contradictory dispute export data") ->setdescription ("Dispute contradictory dispute export data"); $excel->setactivesheetindex (0); $objActSheet=$excel-Getactivesheet (); $SQL= "SELECT * from Dispute order by DispID limit 0,2"; $rst= Db::execute ($SQL, 20011, ' dispute ', ' admin ', ', ', ' query '); $arr=Split("\1",$rst); $row=2; foreach($arr as $rs){ $col=0; $VALARR=Split("\2",$rs); foreach($VALARR as $val) { $objActSheet->setcellvaluebycolumnandrow ($col,$row,$val); $col++; } $row++; } $objWriter= Phpexcel_iofactory::createwriter ($excel, ' Excel5 '); $objWriter->save (Str_replace('. php ', '. xls ',__file__));
PHP Export Excel