PhpWord将图像添加到表格单元格

PhpWord将图像添加到表格单元格,php,image,phpword,Php,Image,Phpword,我想替换文档中的变量(test_var),我可以创建一个表并使用addText向其中添加文本,但是addImage方法不添加图像 这是我的密码: $template = new \PhpOffice\PhpWord\TemplateProcessor("test.docx"); $table = new \PhpOffice\PhpWord\Element\Table(); $table->addRow(); $table->addCell()->add

我想替换文档中的变量(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是的,它只是添加了一个空图像。