我在加载模板时渲染HTML标记时遇到问题。我使用HTMLtoOpenXML来渲染它,但最后它只是简单的代码。 我用这个:
$workDescription = $entity->getWorkDescription();
$workDescription = \HTMLtoOpenXML::getInstance()->fromHTML(str_replace("<br />","<br>", stripslashes($workDescription)));
$workDescription = $this->replaceSpecialChar($workDescription);
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$document = $phpWord->loadTemplate($templatePath);
$document->setValue('Description', $workDescription);
$document->saveAs($file);
PhpWord加载文档,并从变量设置描述,但输出在渲染文档中是这样的:
<w:p>
<w:pPr>
<w:pStyle w:val='OurStyle2'/>
</w:pPr>
<w:r>
<w:t xml:space='preserve'>
Test of CK Editor tags to transform them to word,
</w:t>
</w:r>
</w:p>
<w:p>
<w:pPr>
<w:pStyle w:val='OurStyle2'/>
</w:pPr>
<w:r>
<w:t xml:space='preserve'>
With a paragraph
</w:t>
</w:r>
</w:p>
如果我不使用HTMLtoOpenXML,我会得到:
<p>Test of CK Editor tags to transform them to word,</p>
<p>With a paragraph</p>
所以这看起来像我错过了什么。有什么帮助吗?