Home >Backend Development >PHP Tutorial >Example of exporting data to excel file format

Example of exporting data to excel file format

WBOY
WBOYOriginal
2016-07-25 08:49:221018browse
Example of exporting PHP data to excel file format
  1. $db = M('dazhuanpan_log');
  2. if($user['ismain'] != 1 && $user['uid'] != '')
  3. $condition[' uid'] = $user['uid'];
  4. $id = $this->_get('iid');
  5. $condition['oid'] = $id;
  6. $condition['prize'] = array ("neq","null");
  7. $condition['openid'] = array("neq","");
  8. $list = $db->where($condition)->select() ;
  9. $info = M("dazhuanpan")->where("id=$id")->find();
  10. $xlsName = $info['topic'] . "Winning statistics" . date( "YmdHis",time());
  11. $xlsCell = array(
  12. array('id','number'),
  13. array('openid','WeChat OPENID'),
  14. array('prize','Winning content '),
  15. array('tel','phone'),
  16. );
  17. //The header of the exported file name gets the data from the database. Note that it corresponds to the header.
  18. $this->exportExcel($xlsName,$xlsCell,$list);//This way you can export the excel file.
  19. ?>
Copy code


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:fsockopen access URLNext article:fsockopen access URL