Forum


Replies: 6   Views: 4898
Replace table variable
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 neiron  · 31-05-2016 - 11:37

I need to use the templates as It planned that the user will create a template and specify which fields he wants in the table. 

Example table (template docx-file):

____________________________________________
|_____________$header$___________________|
|___$val1$___|___$val2$___|___ $val3$___|

 

$docx = new CreateDocxFromTemplate('../../files/TemplateSimpleTable.docx');
$data = array(
                array(
                'val1' => '1',
                'val2' => '2',   
                'val3' => '3',            
                ),
                array(
                'val1' => '4',
                'val2' => '5',   
                'val3' => '6',            
                ),
                array(
                'val1' => '7',
                'val2' => '8',   
                'val3' => '9',            
                ),
        );
$docx->replaceTableVariable($data, array('parseLineBreaks' => true));
$docx->createDocx('example_replaceTableVariable_1');

The number of rows I do not know in advance. Those. is N-lines. Then he will go again connected cells, then again a lot of lines, etc.