Home > php教程 > php手册 > 利用php生成word文档

利用php生成word文档

WBOY
Release: 2016-06-13 09:33:15
Original
909 people have browsed it

   利用php生成word文档,生成的word文件可以用word,wps等软件打开。具体代码如下:

  function word($data,$fileName=""){

  if(empty($data)) return "";

  $data="".$data."";

  if(empty($fileName)) $fileName=date("YmdHis").".doc";

  $fp=fopen($fileName,"wb");

  fwrite($fp,$data);

  fclose($fp);

  }

  示例如下:

  

  $str="

  

利用php创建word文档

 

  作者:Alixixi.com

  


 

  

如果你打开word.doc,看到了这里的介绍,则说明word文档创建成功了。

 

  

 

  版权所有:

  
www.Alixixi.com

  


";

 

  word($str);

  效果图:

source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template