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

<?php
// 根據模板生成用戶信息word
$templateProcessor = new TemplateProcessor("./a.docx");
$templateProcessor->setValue('user', '周起');
$templateProcessor->setValue('email', '445864742@qq.com');
$templateProcessor->saveAs("./b.docx");
相關文章
相關標籤/搜索