Forum


Replies: 2   Views: 2970
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 dev@ram  · 11-05-2017 - 18:40

I have a table with 3 columns. I'm trying to make the 3 columns the same size.

I used the following code as per docs. I get the table rendered but the column widths are

not equal. Is something wrong ?

//the column data

$image = new WordFragment($docx);
    $options = array(
    'src' => $tImg,
    'imageAlign' => 'center',
    'scaling' => 80,
    'spacingTop' => 10,
    'spacingBottom' => 0,
    'spacingLeft' => 0,
    'cellSpacing' => 15,    
    'spacingRight' => 0,
    'textWrap' => 0,
    );
    $image->addImage($options);
    $tblRows[] = array(array('colspan' => 3,'value' => $image));
    $tlabel = new WordFragment($docx);
    $tlabel->addText(array(array('text' => 'Stat 1 ','bold' => true,'fontSize' => 10)));
    $ilabel = new WordFragment($docx);
    $ilabel->addText(array(array('text' => 'Stat 2 ','bold' => true,'fontSize' => 10)));
    $mlabel = new WordFragment($docx);
    $mlabel->addText(array(array('text' => 'Stat3','bold' => true,'fontSize' => 10)));
    $tblRows[] = array($tlabel,$ilabel,$mlabel);

//table config

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