Replies: 2   Views: 1271
Adjust column size issue
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by admin  · 12-05-2017 - 07:20


The default behaviour of MS Word is autofit table widths. You can set column widths but if the content of a cell doesn't fit a width then MS Word increase it width automatically.

You can force column widths setting tableLayout as fixed:

$tblConfig = array(
        'border' => 'single',
        'cellMargin' => 125,
        'tableStyle' => 'TableGridPHPDOCX',
        'tableAlign' => 'center',
        'columnWidths' => array(1000,1000,1000),
        'textProperties' => array('font' => 'Arial', 'fontSize' => 10),
        'tableLayout' => 'fixed',
$docx->addTable($tblRows, $tblConfig);

This option is explained on the addTable API page: