Skip to content

Using table tag in HTML Reader produces no output #324

@EK1771

Description

@EK1771

Sample Code:

$phpWord = new \PhpOffice\PhpWord\PhpWord();

$section = $phpWord->addSection();

$html = '<table><tr><td>test</td></tr></table>';

\PhpOffice\PhpWord\Shared\Html::addHtml($section, $html);

$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
$objWriter->save('test.docx');

Expected Output:

Table with one cell containing the word "test".

Actual Output:

Blank

From stepping through the code quickly, the issue seems to be caused by the following if condition in parseChildNodes():

if ($element instanceof AbstractContainer) {
    self::parseNode($cNode, $element, $styles, $data);
}

Commenting out the if condition then allows for the sample code above to produce the expected output.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions