Forum


Replies: 2   Views: 3492
Gettemplatevariables
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 smaubian  · 10-11-2011 - 08:03

Any chance i can have the TemplateTable.docx file attached to this example ?

I need to dynamically create a table and i think this method is the best to fit my requirements but i was not able to figure how to declare this in the Word document (ps : i have the pro version)

[code]require_once 'classes/CreateDocx.inc';

$docx = new CreateDocx();

$docx->addTemplate('TemplateTable.docx');

$settings = array(
'header' => true
);

$docx->addTemplateVariable(
array(
array(
'NAME' => 'Product A',
'WEIGHT' => '10',
'PRICE' => '5',
),
array(
'NAME' => 'Product B',
'WEIGHT' => '20',
'PRICE' => '30',
),
array(
'NAME' => 'Product C',
'WEIGHT' => '25',
'PRICE' => '7',
),
),
'table',
$settings
);

$docx->addTemplateVariable('TOTALWEIGHT', '55');

$docx->addTemplateVariable('TOTALPRICE', '42');

$docx->addTemplateVariable('MYNAME', 'David Hume');

$docx->createDocx('template_table.docx');
[/code]

Posted by smaubian  · 11-04-2013 - 12:13

Problem solved