PHPWord icon indicating copy to clipboard operation
PHPWord copied to clipboard

border not showing in a table when parse the doc from html

Open guypeled1 opened this issue 5 years ago • 2 comments

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

guypeled1 avatar Apr 24 '20 19:04 guypeled1

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'

lubosdz avatar Jul 13 '20 15:07 lubosdz

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.

devfake avatar Dec 21 '20 15:12 devfake