@@ -464,6 +464,58 @@ public function testParseTableAndCellWidth(): void
464464 self ::assertEquals ('dxa ' , $ doc ->getElement ($ xpath )->getAttribute ('w:type ' ));
465465 }
466466
467+ /**
468+ * Parse heights in rows, which also allows for controlling column height.
469+ */
470+ public function testParseTableRowHeight (): void
471+ {
472+ $ phpWord = new PhpWord ();
473+ $ section = $ phpWord ->addSection ([
474+ 'orientation ' => \PhpOffice \PhpWord \Style \Section::ORIENTATION_LANDSCAPE ,
475+ ]);
476+
477+ $ html = <<<HTML
478+ <table>
479+ <tr style="height: 100px;">
480+ <td>100px</td>
481+ </tr>
482+ <tr style="height: 200pt;">
483+ <td>200pt</td>
484+ </tr>
485+ <tr>
486+ <td>
487+ <table>
488+ <tr style="height: 300px;">
489+ <td>300px</td>
490+ </tr>
491+ </table>
492+ </td>
493+ </tr>
494+ </table>
495+ HTML ;
496+
497+ Html::addHtml ($ section , $ html );
498+ $ doc = TestHelperDOCX::getDocument ($ phpWord , 'Word2007 ' );
499+
500+ // <tr style="height: 100; ... 100px = 1500 twips (100 / 96 * 1440)
501+ $ xpath = '/w:document/w:body/w:tbl/w:tr/w:trPr/w:trHeight ' ;
502+ self ::assertTrue ($ doc ->elementExists ($ xpath ));
503+ self ::assertEquals (1500 , $ doc ->getElement ($ xpath )->getAttribute ('w:val ' ));
504+ self ::assertEquals ('exact ' , $ doc ->getElement ($ xpath )->getAttribute ('w:hRule ' ));
505+
506+ // <tr style="height: 200pt; ... 200pt = 4000 twips (200 / 72 * 1440)
507+ $ xpath = '/w:document/w:body/w:tbl/w:tr[2]/w:trPr/w:trHeight ' ;
508+ self ::assertTrue ($ doc ->elementExists ($ xpath ));
509+ self ::assertEquals (4000 , $ doc ->getElement ($ xpath )->getAttribute ('w:val ' ));
510+ self ::assertEquals ('exact ' , $ doc ->getElement ($ xpath )->getAttribute ('w:hRule ' ));
511+
512+ // <tr style="width: 300; .. 300px = 4500 twips (300 / 72 * 1440)
513+ $ xpath = '/w:document/w:body/w:tbl/w:tr[3]/w:tc/w:tbl/w:tr/w:trPr/w:trHeight ' ;
514+ self ::assertTrue ($ doc ->elementExists ($ xpath ));
515+ self ::assertEquals (4500 , $ doc ->getElement ($ xpath )->getAttribute ('w:val ' ));
516+ self ::assertEquals ('exact ' , $ doc ->getElement ($ xpath )->getAttribute ('w:hRule ' ));
517+ }
518+
467519 /**
468520 * Test parsing table (attribute border).
469521 */
0 commit comments