【发布时间】:2021-01-24 13:14:25
【问题描述】:
我想替换文档中的变量(test_var),我可以创建一个表格并用addText向其中添加文本,但是addImage方法没有添加图像。
这是我的代码:
$template = new \PhpOffice\PhpWord\TemplateProcessor("test.docx");
$table = new \PhpOffice\PhpWord\Element\Table();
$table->addRow();
$table->addCell()->addText("test");
$table->addCell()->addImage("test.png");
$template->setComplexBlock('table_var', $table);
$template->saveAs("test_.docx");
- PHP 版本:7.4
- PhpWord 版本:0.17.0
【问题讨论】:
-
你确定路径正确吗?
-
@SimoneRossaini 是的,它只是添加一个空图像。