如何用phpword设置表格宽度?

Sol*_*nka 2 php phpword

文档说可以在 addTable 中设置表格宽度,但我不明白如何使其工作。另外我需要设置我尝试过的 100% 宽度:

$table = $section->addTable(array(
  'width' => 100
));
$table = $section->addTable(array(
  'width' => '100'
));
$table = $section->addTable(array(
  'width' => '100%'
));
Run Code Online (Sandbox Code Playgroud)

但似乎没有任何作用。我应该写什么才能让它发挥作用?

小智 6

尝试这个...

$table = $section->addTable(array('unit' => \PhpOffice\PhpWord\Style\Table::WIDTH_PERCENT, 'width' => 100 * 50));