我正在尝试使用 phpWord 将 html 输出到单词。然而,有些奇怪。它适用于以下代码:
$content = '';
$content .= '<table><tr><th>Header</th><td>Content</td></tr></table>';
$content .= '<ul><li>Bullet</li><ul><li>Bullet</li></ul></ul>';
$content .= '<ol><li>Bullet</li></ol>';
Html::addHtml($newSection, $content);
但不适用于此:
$content = '';
$content .= '<table><tr><th>Header</th><td>Content</td></tr></table>';
$content .= '<p>Bullet</p>';
$content .= '<p>Cat</p>';
Html::addHtml($newSection, $content);
并产生标题中提到的错误。
更新
此错误是从此文件生成的:\vendor\phpoffice\phpword\src\PhpWord\Shared\Html.php
在这种方法中:
private static function parseChildNodes($node, $element, $styles, $data)
{
if ('li' != $node->nodeName) {
$cNodes = $node->childNodes;
if (count($cNodes) > 0) {
foreach ($cNodes as $cNode) {
if ($element instanceof AbstractContainer) {
self::parseNode($cNode, $element, $styles, $data);
}
}
}
}
}
但这仅在使用<p>html 标签时发生,并且适用于所有其他标签。
我也遇到了这个链接:addHtml() 不支持列表标签内的标签。#521