Forum


Replies: 5   Views: 3267
Template table header example not working with changes
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 inca.sistemas  · 04-04-2011 - 15:09

Hello,

I have try the template_header.php example... and it runs OK, but if I put these in DOCX:

Weight (Kg) Price (€)
$NMONTE$ $RECINTO$ $SUP$
Total $TOTAL1$ $TOTAL2$

INSTEAD ........

Weight (Kg) Price (€)
$NAME$ $WEIGHT$ $PRICE$
Total $TOTALWEIGHT$ $TOTALPRICE$
--------------------------------

And this in PHP code:


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



$docx->addTemplateVariable(
array(
array(
'NMONTE' => 'Product A',
'RECINTO' => '10',
'SUP' => '5',
),
array(
'NMONTE' => 'Product B',
'RECINTO' => '20',
'SUP' => '30',
),
array(
'NMONTE' => 'Product C',
'RECINTO' => '25',
'SUP' => '7',
),
),
'table',
$settings
);
$docx->addTemplateVariable('TOTAL1', '55');
$docx->addTemplateVariable('TOTAL2', '42');
$docx->addTemplateVariable('MYNAME', 'David Hume');

The result is:

Weight (Kg) Price (€)
Product A 10 5
Product B 20 30
Product C 25 7
$NMONTE$ $RECINTO$ $SUP$
$NMONTE$ $RECINTO$ $SUP$
$NMONTE$ $RECINTO$ $SUP$
$NMONTE$ $RECINTO$ $SUP$
$NMONTE$ $RECINTO$ $SUP$
$NMONTE$ $RECINTO$ $SUP$
$NMONTE$ $RECINTO$ $SUP$
$NMONTE$ $RECINTO$ $SUP$
$NMONTE$ $RECINTO$ $SUP$
$NMONTE$ $RECINTO$ $SUP$
$NMONTE$ $RECINTO$ $SUP$
$NMONTE$ $RECINTO$ $SUP$
$NMONTE$ $RECINTO$ $SUP$
$NMONTE$ $RECINTO$ $SUP$
$NMONTE$ $RECINTO$ $SUP$
$NMONTE$ $RECINTO$ $SUP$
Total 55 42
Total 55 42
Total 55 42
Total 55 42
Total 55 42
Total 55 42


What is happen ?¿?¿?¿?

Posted by inca.sistemas  · 11-04-2013 - 12:12

The PHPDOCX are the best.

The error came from the way i wrote the "variables". Word 2007 write several tags that you can not see... and the phpdocx library can confuse with them.

The solution is write the "variable" (in the template docx) in "one step" including $ symbols... without erase.. or copy... or replace any....."all in one step".

Remember, be careful writing your variables in the docx template....

THANKS TO PHPDOCX TECH. A great job and great people too.

Posted by rthijs  · 11-04-2013 - 12:12

Hi,

First of all : Congratulations with your product

The tables seem to be very sensitive for changes. My users will be changing the templates themself and I am afraid that a lot of problems will arise and a lot of support request will come in.

Therefore is there a way to:

1) Scan a document to see if there is "unwanted" garbage in the tables that will confuse phpDocx

2) Clean a Word doc automatically so the tables will always work.

Other suggestions or workarounds are welcome.;;;

Rita

Posted by admin  · 11-04-2013 - 12:12

Hello,

We're working on new improvements to clean unwanted tags on WordML. The next version of phpdocx will include them.

Regards. Jorge.

Posted by rthijs  · 11-04-2013 - 12:12

Hi,

Thanks we are looking forward to see the next version coming out !

Rita