Use php to generate word documents. The generated word files can be opened with word, wps and other software. The specific code is as follows:
function word($data,$fileName=''){
if(empty($data)) return '';
$data='<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">'.$data.'</html>';
if(empty($fileName)) $fileName=date('YmdHis').'.doc';
$fp=fopen($fileName,'wb');
fwrite($fp,$data);
fclose($fp);
}
Copy after login
Examples are as follows:
<?php
$str='<title>利用php创建word文档</title>
<h1>利用php创建word文档</h1>
作者:phpernote.com
<hr size=1>
<p>如果你打开word.doc,看到了这里的介绍,则说明word文档创建成功了。</p>
<p>
<b>版权所有:</b>
<br>www.phpernote.com
<hr size=1>';
word($str);
Copy after login
Rendering:
Articles you may be interested in
- The idea and implementation method of generating short URLs in PHP
- Several methods of generating random numbers in PHP
- PHP generates a random password function
- A summary of the method of generating a random password in php
- How to generate an image thumbnail in php
- How to generate a QR code in php Summary
- Examples of PHP generating download links for Thunder, Express and QQ Tornado
- PHP generating verification code function
http://www.bkjia.com/PHPjc/764098.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/764098.htmlTechArticleUse php to generate word documents. The generated word files can be opened with word, wps and other software. The specific code is as follows: function word($data,$fileName=''){if(empty($data)) return '';$data='html x...