php将html转入word中

WBOY
Release: 2016-06-23 13:18:08
Original
918 people have browsed it

这是经过测试的,这种方法有一点不好,html页面代码要写在php中,不过好歹能运行,看程序

class word{

function start(){

ob_start();

echo '

xmlns:w="urn:schemas-microsoft-com:office:word"

xmlns="http://www.w3.org/TR/REC-html40">';

}

function save($path)

{

echo "";

$data = ob_get_contents();

}

function wirtefile($fn,$data){

$fp=fopen($fp,$data);

fwrite($fp,$data);

}

}


$html='

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

姓名 性别 年龄 爱好 备注
张三 32 足球
 

  李四 

 

43 篮球
 

';

//批量生成

//for($i=1;$i

$word = new word();

$word->start();

$wordname='个人测试php生成word.doc';

echo $html;

$word->save($wordname);

header('Content-type:application/word');

header('Content-Disposition: attachment; filename='.$wordname.'');

//readfile($wordname);

ob_flush();//每次执行前刷新缓存

flush();


//}

?>


Related labels:
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template