php导出word格式数据的范例代码

WBOY
풀어 주다: 2016-06-13 11:42:51
원래의
1195명이 탐색했습니다.

php导出word格式数据的实例代码

转自:http://www.jbxue.com/article/13631.html

php导出word格式数据的代码实例,有需要的朋友可以参考一下。
本节内容:
一个php导出word文档的类
例子:

点击(此处)折叠或打开

  1. ?php
  2. /**
  3. *?生成word文档的类
  4. *?by www.jbxue.com
  5. */
  6. class?word
  7. {?
  8. ????function start()
  9. ????{
  10. ????????ob_start();
  11. ????????echo?'
  12. ????????xmlns:w="urn:schemas-microsoft-com:office:word"
  13. ????????xmlns="http://www.w3.org/TR/REC-html40">';
  14. ????????}
  15. ????function save($path)
  16. ????{?
  17. ????????echo?"";
  18. ????????$data?=?ob_get_contents();
  19. ????????ob_end_clean();
  20. ????????$this->wirtefile?($path,$data);
  21. ????}
  22. ????function wirtefile?($fn,$data)
  23. ????{
  24. ????????$fp=fopen($fn,"wb");
  25. ????????fwrite($fp,$data);
  26. ????????fclose($fp);
  27. ????}
  28. }
  29. //导出的程序文件
  30. //导出?---start---
  31. require SITE_ROOT.'include/word.class.php';?//类文件放在根目录下的include文件夹下
  32. $word?=?new?word();
  33. //查询数据填入word 中
  34. $result?=?$db->query("SELECT * FROM ".DB_PRE."box where status='9' order by boxid DESC");
  35. while($r?=?$db->fetch_array($result))
  36. {
  37. ??$r['orderinfo']?=?$db->get_one("SELECT * FROM ".DB_PRE."order where orderid='".$r['orderid']."'");
  38. ??$r['wrapinfo']?=?$db->get_one("SELECT * FROM ".DB_PRE."wrap where orderid='".$r['orderid']."'");
  39. ?$boxlist[]?=?$r;
  40. }
  41. ?foreach($boxlist as $key=>$val){?
  42. ????$order->UPCAbarcode($val['box_code']);
  43. ????$html?.=' www.jbxue.com
  44. ????
  45. ?
  46. ??????
  47. ?
  48. ??????
  49. ?
  50. ??????
  51. ?
  52. ??????
  53. ?
  54. ??????
  55. ?
  56. ??????
  57. ?
  58. ????
  59. ?
  60. ????
  61. ?
  62. ??????
  63. ?
  64. ??????
  65. ?
  66. ??????
  67. ?
  68. ??????
  69. ?
  70. ??????
  71. ?
  72. ??????
  73. ?
  74. ????
  75. ?
  76. ????
  77. ?
  78. ??????
  79. ?
  80. ??????
  81. ?
  82. ??????
  83. ?
  84. ??????
  85. ?
  86. ????
  87. ?
  88. ????
  89. ?
  90. ??????
  91. ?
  92. ??????
  93. ?
  94. ????
  95. ?
  96. ????
  97. ?
  98. ??????
  99. ?
  100. ??????
  101. ?
  102. ????
  103. ?
  104. ????
  105. iGo运
    单号
    php导出word格式数据的范例代码].' />
    '
    .$val['box_code'].'
    日期 '.date('Y-m-d',$val[create_date]).' 标示
    姓名
    '.$val[code].'/'.$val['orderid'].'
    '
    .$val['orderinfo']['user_name'].'
    件数 3 重量 56.5 品名 咬咬了,吸盘碗,学饮杯,鱼干油
    服务
    类别
    库房服务 服务
    要求
    合小箱


    客户
    备注

    '.$val['orderinfo']['beizhu'].'



    到货
    情况



    什么问题?果点不到
    什么问题?果点不到
    什么问题?果点不到











  106. ';?
  107. ?}
  108. ?????$word->start();
  109. ?????$filename?=?'拣货单导出.doc';
  110. ?????echo?$html;
  111. ??????$word->save($filename);
  112. ??????//文件的类型
  113. ??????header('Content-type: application/word');
  114. ??????header('Content-Disposition: attachment; filename="拣货单导出.doc"');
  115. ??????readfile($filename);
  116. ??????ob_flush();
  117. ??????flush();
  118. ?????exit();
  119. //导出word?--end--
관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!