Forum


Replies: 12   Views: 4785
Addtemplatevariable only creates first row of 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 lbreu  · 19-01-2012 - 16:41

Hi

I am still trying to figure out this table thing, which is the main reason we purchased phpdocx pro.

I created the simplest template I could think of using Word 2007. It's just a table with the first row containing text (header) and then one row with variables, just like in your demo.

I even enclosed it in $BLOCK_table$, just like the demo. Also there is a variable $vardump$ after that, and that's it.

I then created an array of arrays (3 data rows) and used
$docx->addTemplateVariable($terminData, 'table', array('header' => false));
to create the table. I also replaced the vardump variable with a var_dump of my data array.

The resulting docx has only one row in the table (plus the fixed header), but the vardump shows that there are actually three items in the array (each of which is itself an array of course).

What could be the problem?
Things I checked:
- special chars like Umlauts --> not the reason, there are none in my testdata
- empty variables --> not the reason, if I prepend "foo" to all values, it still only creates one row

What am I doing wrong? I really need this to work, but I seem to be missing something here. I would gladly send you the template and the resulting docx as well as some more code, if you could give me an idea on how to fix this...

Cheers,
Lorenz