思路解说 word 模板文件(doc 或 docx 文件)另存为 xml 文件 将后缀 xml 改成 html:大部分文档会改成 ftl(FreeMarker 的后缀名),因为 word 文件另存为 xml 文件后,xml 文件中的代码很乱,后面的修改会很麻烦,因为我习惯用 VSCode 编辑器,安装 Beautify 插件后,可以自动格式化 html 代码,这样有利于后面的修改 将内容用${param}替换:例:姓名:月牙坠-->姓名:${name} word 文件中的图片是 Base64 编
下载地址https://www.cnwenhui.cn/html/show-597.html(其中有中文使用手册可以下载看看) 1.首先要下载Phpword类库,放在如下图目录下 2.调用方法 public function daochuword() { vendor("PHPWord.PHPWord"); // New Word Document $PHPWord = new \PHPWord(); // New portrait section $section = $PHPWor