Blogger Information
Blog 39
fans 1
comment 0
visits 62270
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php生成word文档
Dai的博客
Original
1857 people have browsed it
class word
{
    function start()
    {
        ob_start();
        echo '<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">';
    }
    function save($path)
    {

        echo "</html>";
        $data = ob_get_contents();
        ob_end_clean();

        $this->wirtefile ($path,$data);
    }

    function wirtefile ($fn,$data)
    {
        $fp=fopen($fn,"wb");
        fwrite($fp,$data);
        fclose($fp);
    }
}
$html = ' 
<table width=600 cellpadding="6" cellspacing="1" bgcolor="#000"> 
<tr bgcolor="White"> 
 <td>dmy</td> 
 <td><a href="" target="_blank" >dmy</a></td> 
</tr> 
<tr bgcolor="red"> 
 <td>dai</td> 
 <td><a href="" target="_blank" >dai</a></td> 
</tr> 
<tr bgcolor="White"> 
 <td colspan=2 > 
 dd<br> 
 </td> 
</tr> 
</table> 
';

//批量生成
for($i=1;$i<=1;$i++){
    $word = new word();
    $word->start();
    //$html = "aaa".$i;
    $wordname = $_SERVER['DOCUMENT_ROOT'].'/chinaBank/word/dd.doc';
    echo $html;
    $word->save($wordname);
    ob_flush();//每次执行前刷新缓存
    flush();
}


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post