Home  >  Article  >  Backend Development  >  A small example of php generating xls file

A small example of php generating xls file

WBOY
WBOYOriginal
2016-07-25 08:56:151055browse
  1. include '../../inc/auth.php';

  2. include '../public/Base.php';
  3. include '../public /BoonList.php';
  4. //The above is the code for pdo to connect to the database, you can complete it by yourself.
  5. header('Cache-Control: no-cache, must-revalidate');
  6. header('Content-type: application/vnd.ms-excel');
  7. header('Content-Disposition: filename=leaveMessage.xls' );
  8. ?>
  9. < ;td nowrap>Message content
  10. < ?php
  11. if (isset($_GET['trio']) && $_GET['trio']=='trio_message') {
  12. $sql = "select * from trio_message";
  13. $order_list = $db-> getAll($sql);

  14. for($i=0;$i

  15. echo '
  16. ' ;
  17. echo'
  18. ';
  19. echo'
  20. ';
  21. echo'
  22. ';
  23. echo'
  24. ';
  25. echo'
  26. ' ;
  27. echo '
  28. ';
  29. }
  30. }
  31. ?>
  32. Message ID
  33. userid username Date
    '.$order_list[$i]["id"].' '.$order_list[$i]["userid "].' '.$order_list[$i]["user_name"].' ' .$order_list[$i]["content"].' '.$order_list[$i]["fdate"].'
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