php根据word模板生成新的word文件


原文地址:http://www.niu12.com/article/16

php使用phpword将word内容变量替换

a.安装phpword

 composer require phpoffice/phpword

b.当前目录下a.docx,假设word内容需要替换的变量为

说明人:${user}
电话:${email}

c.php改写word内容

参考地址

<?php
// 根据模板生成用户信息word
$templateProcessor = new TemplateProcessor("./a.docx");
$templateProcessor->setValue('user', '周起');
$templateProcessor->setValue('email', '445864742@qq.com');
$templateProcessor->saveAs("./b.docx");


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM