Forum


Replies: 1   Views: 3021
Width in table
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 General research Computer Center  · 25-09-2016 - 16:57

How to set the width of columns?
tableData:width OR tableProperties: columnWidths?

If I have a simple table that works: columnWidths

But my table have WordFragment then  columnWidths not working

Posted by admin  · 26-09-2016 - 14:07

Hello,

This sample uses columnWidths and WordFragments (it's included within all packages as example):

<?php

require_once 'classes/CreateDocx.inc';

$docx = new CreateDocx();

// create a few Word fragments to insert rich content in a table

$link = new WordFragment($docx);
$options = array(
    'url' => 'http://www.google.es'
);

$link->addLink('Link to Google', $options);

$image = new WordFragment($docx);
$options = array(
    'src' => '../../img/image.png'
);

$image->addImage($options);

$valuesTable = array(
    array(
        'Title A',
        'Title B',
        'Title C'
    ),
    array(
        'Line A',
        $link,
        $image
    )
);


$paramsTable = array(
    'tableStyle' => 'LightListAccent1PHPDOCX',
    'tableAlign' => 'center',
    'columnWidths' => array(1000, 2500, 3000),
    );

$docx->addTable($valuesTable, $paramsTable);

$docx->createDocx('example_addTable_2');

Regards.