PHPWord
PHPWord copied to clipboard
border not showing in a table when parse the doc from html
Hi, i am using the phpword in a laravel project. this is my code: ` $pw = new \PhpOffice\PhpWord\PhpWord();
/* [THE HTML] */
$section = $pw->addSection();
$html = "<h1>HELLO WORLD!</h1>";
$html .= "<p style='color:red;'>This is a paragraph of random text</p>";
$html .= "<table style='border:5px solid black'><tr><td>A table</td><td><ul><li>Cell</li><li>Cell</li></ul></td></tr></table>";
\PhpOffice\PhpWord\Shared\Html::addHtml($section, $html, false, false);
/* [SAVE FILE ON THE SERVER] */
$pw->save( storage_path("html-to-doc.docx"), "Word2007");
` i copied the code from the exampla and added the border. for some reasone the border is not showing in the table.
Thanks
Border parser requires to stick with exact order: width + color + style
You have used: table style='border:5px solid black' (= width + style + color).
In order to make it work switch solid and black: table style='border:5px black solid'
If someone has problems with borders, try this out:
style="border-color: black; border-width: 3px; border-style: solid"
It took me a lot of time to find this out from the source code directly.