Hello,
You can use the tableWidth option by applying a 100 pct value:
'tableWidth' => array('type' => 'pct', 'value' => 100),
or a fixed width (dxa):
'tableWidth' => array('type' => 'dxa', 'value' => 8500),
and also use columnWidths:
'columnWidths' => array(2125,2125,2125,2125),
MS Word allows working with auto values (pct and auto sizes), so you don't need to set the exact cell widths, but some DOCX readers can't work with auto values as MS Word does. Google Docs has some limitations when working with DOCX documents.
For example, the following code generates a table from left margin to right margin using the default page size by setting specific sizes instead of auto values:
$docx = new CreateDocx();
$values = array(
array(
11,
12,
13,
14
),
array(
21,
22,
23,
24
),
);
$options = array(
'columnWidths' => array(2125,2125,2125,2125),
'tableWidth' => array('type' => 'dxa', 'value' => 8500),
);
$docx->addTable($values, $options);
$docx->createDocx('output');
Both the tableWidth (dxa type) and columnWidths options use twips (Twentieth of a Point) as their unit of measurement. As a reference, 8500 twips correspond to the default A4-size section.
Regards.