Forum


Replies: 3   Views: 569
Template with fixed height table rows
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  · 30-06-2023 - 16:41

Hello,

You can use DOCXCustomizer to change styles on-the-fly.

For example:

$docx = new CreateDocx();

$trProperties = array();
$trProperties[1] = array(
    'height' => 567,
);

$values = array(
    array(
        11,
        12,
        13,
        14
    ),
    array(
        21,
        22,
        23,
        24
    ),
    array(
        31,
        32,
        33,
        34
    ),

);

$docx->addTable($values, array(), $trProperties);

$docx->createDocx('output_1');

$docx = new CreateDocxFromTemplate('output_1.docx');

// get the content to be changed
$referenceNode = array(
    'type' => 'table-row',
    'occurrence' => 2,
    'parent' => 'w:tbl[1]/',
);

$docx->customizeWordContent($referenceNode,
    array(
        'height' => 1067,
    )
);

$docx->createDocx('output_2');

Please note that in this case at least one row style must exist to handle it.

In the examples/DocxCustomizer folder of the Premium package you can find many samples using this method. For example, sample_10.php creates and updates a table using addTable and DOCXCustomizer.

DOCXPath methods allows to query contents to get information and do other tasks: https://www.phpdocx.com/documentation/introduction/docxpath

Please note that in these cases, with a very specific task to be done, we recommend opening a support ticket (https://www.phpdocx.com/support) with a sample DOCX and the output you want to get, so the dev team can generate a custom script using it or even adding a minor new feature or new method if the task require it.

Regards.