0

When I add a cell to a table, I can manipulate its thickness (borderBottomSize), its color (borderBottomColor) but not its style (dashed, dotted, longdashed, ...).

When I read the code, the PhpOffice\PhpWord\Style\Cell extends the PhpOffice\PhpWord\Style\Border. And the border class has the attribute borderBottomStyle. But how to configure that?

I also looked into the PhpOffice\PhpWord\Style\Line, there I can find some "dashStyles", but none of them are working...

My question: How to change style of border (from strong line to for example dotted)?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

1 Answers1

0

You can define the style of the border by using the cell style property borderStyle. By default, it's set to solid, but you can use other values like dashed, dotted, double, etc. Sadly, this feature is not documented so I don't know all the available styles.

Don't forget to add a border size as well, otherwise no border will be rendered.

Example for a dotted cell:

$dottedCell = $tableRow->addCell($cellWidth, ['borderStyle' => 'dotted', 'borderSize' => 6]);
Christian Fries
  • 444
  • 3
  • 12
  • does there a way to make border raduis ? – famas23 Mar 23 '21 at 12:37
  • No, Microsoft Word (and therefore also PhpWord) does not provide an option to set a border radius on tables – Christian Fries Mar 23 '21 at 15:27
  • Hey, thank your for your answer, so there's no way to do a radius box w a text inside ! – famas23 Mar 23 '21 at 15:41
  • While it's definitely not possible for tables that doesn't mean it's not possible at all. You might want to experiment with [textboxes](https://github.com/PHPOffice/PHPWord/blob/develop/samples/Sample_25_TextBox.php) or [shapes](https://github.com/PHPOffice/PHPWord/blob/develop/samples/Sample_31_Shape.php) – Christian Fries Mar 23 '21 at 16:17
  • text boxes doest not support bg color, and shapes does not allow to write text inside the shape :/ – famas23 Mar 23 '21 at 16:45