Skip to content

Colspan and rowspan not working on the HTML Writer #1283

@lnicorena

Description

@lnicorena

This is:

  • a bug report

Expected Behavior

To properly generate the colspan and rowspan properties, when loading a docx document containing tables (with merged cells) and convert it to html

Current Behavior

The colspan and rowspan properties (loaded from tables in a docx ) are being ignored by the HTML Writer. I believe that by the other Writers too.

Failure Information

When a table like this is loaded,

screen shot 2018-02-15 at 15 02 49

This is the html output:
screen shot 2018-02-15 at 15 06 14

<table>
<tbody><tr>
<td>
<p style="text-align: center; margin-top: 0; margin-bottom: 0;">A</p>
</td>
<td>
<p style="text-align: center; margin-top: 0; margin-bottom: 0;">B</p>
</td>
<td>
<p style="text-align: center; margin-top: 0; margin-bottom: 0;">C</p>
<p style="text-align: center; margin-top: 0; margin-bottom: 0;">R</p>
</td>
<td>
<p style="text-align: center; margin-top: 0; margin-bottom: 0;">D</p>
</td>
</tr>
<tr>
<td>
<p style="text-align: center; margin-top: 0; margin-bottom: 0;">Q</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>&nbsp;</p>
</td>
</tr>
<tr>
<td>
<p style="text-align: center; margin-top: 0; margin-bottom: 0;">Z</p>
</td>
<td>
<p style="text-align: center; margin-top: 0; margin-bottom: 0;">E</p>
</td>
<td>
<p>&nbsp;</p>
</td>
</tr>
</tbody></table>

How to Reproduce

$template ='path/to/document.docx';
$phpWord = \PhpOffice\PhpWord\IOFactory::load($template);
$htmlWriter = new \PhpOffice\PhpWord\Writer\HTML($phpWord);
$htmlString = $htmlWriter->getContent();
print $htmlString;

Context

  • PHP version: 7.2.0
  • PHPWord version: 0.13.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions