PHPexcel: How to export garbled data in PHP 2003 and other versions? but how to export garbled data in excel2007:
String format for excel to export. Valid value are 'excel5', 'excel2007 ', 'excel2003xml', '00calc', 'gnumeric '.
Find the createWrite method and change the second parameter to the EXCEL version to be generated:
For example:
$ ObjWriter = PHPExcel_IOFactory: createWriter ($ objPHPExcel, 'excel5'); $ objWriter-> save ('php: // output ');
Of course, if the framework is used, such as the YII2 framework, it is recommended to encapsulate it into a small object. recommended:
Https://github.com/moonlandsoft/yii2-phpexcel
Usage of small objects:
Use moonland \ phpexcel \ Excel; public function actionT () {$ result = Test: find ()-> all (); Excel :: widget (['models' => $ result, 'mode' => 'port', 'format' => 'excel5', 'columns '=> ['itemid ', 'username', 'Company'], 'headers' => ['itemid' => 'Id ', 'username' => 'username ', 'Company' => 'Company'],]);}