龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > php编程 >

PHPWORD

时间:2014-07-22 14:48来源: 作者: 点击:
分享到:
使用模板,批量生成Word。
使用模板,批量生成Word。
建立一个Word文件Template.docx
欲替换的值地方${name}
思路:
仿照smarty,
模板文件一定要命名为docx,后缀
前提,先下载开源类PHPWord,PHP开启ZIP拓展
<?php
	require_once 'PHPWord.php';
	$PHPWord  = new PHPWord();
	$document = $PHPWord->loadTemplate('Template.docx');
        $document->setValue('name', 'xeay');
	$document->setValue('class', '软件一班');
	$document->setValue('No', '1108000xxxx');
	$document->setValue('telephone', '1885022xxxx');
	$document->setValue('why', 'ACM');
	$document->setValue('signname', 'xeay'); 
	$document->save('image.docx');
?>
精彩图集

赞助商链接