diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php index 3b8d587f..f57fb0a9 100644 --- a/src/PhpWord/Shared/Html.php +++ b/src/PhpWord/Shared/Html.php @@ -372,17 +372,11 @@ class Html $newElement = $element->addTable($elementStyles); - // $attributes = $node->attributes; - // if ($attributes->getNamedItem('width') !== null) { - // $newElement->setWidth($attributes->getNamedItem('width')->value); - // } - - // if ($attributes->getNamedItem('height') !== null) { - // $newElement->setHeight($attributes->getNamedItem('height')->value); - // } - // if ($attributes->getNamedItem('width') !== null) { - // $newElement=$element->addCell($width=$attributes->getNamedItem('width')->value); - // } + $attributes = $node->attributes; + if ($attributes->getNamedItem('border') !== null) { + $border = (int) $attributes->getNamedItem('border')->value; + $newElement->getStyle()->setBorderSize(Converter::pixelToTwip($border)); + } return $newElement; } diff --git a/tests/PhpWord/Shared/HtmlTest.php b/tests/PhpWord/Shared/HtmlTest.php index eecec002..fdf3e37c 100644 --- a/tests/PhpWord/Shared/HtmlTest.php +++ b/tests/PhpWord/Shared/HtmlTest.php @@ -351,6 +351,35 @@ class HtmlTest extends AbstractWebServerEmbeddedTest $this->assertFalse($doc->elementExists('/w:document/w:body/w:tbl/w:tr[1]/w:tc[2]/w:p/w:pPr/w:pBdr')); } + /** + * Test parsing table (attribute border) + */ + public function testParseTableAttributeBorder() + { + $phpWord = new \PhpOffice\PhpWord\PhpWord(); + $section = $phpWord->addSection(); + $html = '
| Header | +
|---|
| Cell 1 |
| Cell 2 |