Replies: 5   Views: 3040
Add a table to a 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 peter  · 02-04-2013 - 18:53


I would like to add a table to a template variable; is that possible and how?

I've a template with several variables in it,one should be replaced with atable that is created for each time;

I've done this:

first i've an array of arrays; $arrays
then I create an instance of an table
$table = CreateTable::getInstance();
after that I createTable with my data
$table -> createTable($arrays, array('border' => 'none',));

them I utf8_encode all my variables including the table, if I skip that I get error

and then I add the table to the variable (and all other ariables)
$doc -> addTemplateVariable("variable",$table)

The table is only added as a string of the xml code and not interpreted as a table ('<w:tbl><w:tblPr><w:tblStyle w:val="TableGridPHPDOCX"><..........')

version is Pro 3.2, and I thinnk I had this working on 2.x but now when I tried it the variable wasreplaced with emptiness.