I have a problem using the template function.
The code of my PHP script is:
require_once 'Classes/PHPWord.php';
$PHPWord = new PHPWord();
$document = $PHPWord->loadTemplate($Template);
$document->setValue('Value1', $Cliente.' ('.$CodiceFiscale.')');
$document->setValue('Value2', $Classificazione1);
$document->setValue('Value3', $Classificazione2);
$document->setValue('Value4', $Classificazione3);
$document->setValue('Value5', $PianoFabbisogni1);
$document->setValue('Value6', $PianoFabbisogni2);
$document->setValue('Value7', $NotePianoFabbisogni);
$document->setValue('Value8', $ContrattoFornitura1);
$document->setValue('Value9', $ContrattoFornitura2);
$document->setValue('Value10', $NoteContrattoFornitura);
$document->setValue('Value11', $AltraDocumentazione);
$document->setValue('Value12', $Intranet1);
$document->setValue('Value13', $Infranet1);
$document->setValue('Value14', $Internet1);
$document->setValue('Value15', $TipologiaServizi);
$document->setValue('Value16', $CanoneAnnuo);
$document->setValue('Value17', $UnaTantum);
$document->setValue('Value18', $NumeroServizi);
$document->setValue('Value19', $DataContratto);
$document->setValue('Value20', $Difformita1);
$document->setValue('Value21', $Difformita2);
$document->setValue('Value22', $AltreNote);
$document->setValue('Value23', $RisultatoRiesame1);
$document->setValue('Value24', $RisultatoRiesame2);
$document->setValue('Value25', $Funzione1);
$document->setValue('Value26', $Data1);
$document->setValue('Value27', $NomeCognome1);
$document->setValue('Value28', $Funzione2);
$document->setValue('Value29', $Data2);
$document->setValue('Value30', $NomeCognome2);
$document->save($NomeFile);
I've modified the word template and now the values are from "Value1" to "Value30".
The output file is saved but, when I open that, only values from 1 to 10 are modified.
Please.....help me
Comments: Hi, It was a problem for me that I could not do search and replace on strings inside paragraphs. I removed the check for the {} braces around the keyword search and instead use a unique prefix (in my case zzz<fieldname>). It's working perfectly for me. so my template looks something like this: Dear zzzFullName, Your letter dated zzletterdate, with reference zzreference .... ---------------------- works like a charm. Using the SearchReplace image routine that somebody else made, also allowed me to add a signature to the template that I was using. Both of these things have made phpWord successful in my testing. Thanks.
The code of my PHP script is:
require_once 'Classes/PHPWord.php';
$PHPWord = new PHPWord();
$document = $PHPWord->loadTemplate($Template);
$document->setValue('Value1', $Cliente.' ('.$CodiceFiscale.')');
$document->setValue('Value2', $Classificazione1);
$document->setValue('Value3', $Classificazione2);
$document->setValue('Value4', $Classificazione3);
$document->setValue('Value5', $PianoFabbisogni1);
$document->setValue('Value6', $PianoFabbisogni2);
$document->setValue('Value7', $NotePianoFabbisogni);
$document->setValue('Value8', $ContrattoFornitura1);
$document->setValue('Value9', $ContrattoFornitura2);
$document->setValue('Value10', $NoteContrattoFornitura);
$document->setValue('Value11', $AltraDocumentazione);
$document->setValue('Value12', $Intranet1);
$document->setValue('Value13', $Infranet1);
$document->setValue('Value14', $Internet1);
$document->setValue('Value15', $TipologiaServizi);
$document->setValue('Value16', $CanoneAnnuo);
$document->setValue('Value17', $UnaTantum);
$document->setValue('Value18', $NumeroServizi);
$document->setValue('Value19', $DataContratto);
$document->setValue('Value20', $Difformita1);
$document->setValue('Value21', $Difformita2);
$document->setValue('Value22', $AltreNote);
$document->setValue('Value23', $RisultatoRiesame1);
$document->setValue('Value24', $RisultatoRiesame2);
$document->setValue('Value25', $Funzione1);
$document->setValue('Value26', $Data1);
$document->setValue('Value27', $NomeCognome1);
$document->setValue('Value28', $Funzione2);
$document->setValue('Value29', $Data2);
$document->setValue('Value30', $NomeCognome2);
$document->save($NomeFile);
I've modified the word template and now the values are from "Value1" to "Value30".
The output file is saved but, when I open that, only values from 1 to 10 are modified.
Please.....help me
Comments: Hi, It was a problem for me that I could not do search and replace on strings inside paragraphs. I removed the check for the {} braces around the keyword search and instead use a unique prefix (in my case zzz<fieldname>). It's working perfectly for me. so my template looks something like this: Dear zzzFullName, Your letter dated zzletterdate, with reference zzreference .... ---------------------- works like a charm. Using the SearchReplace image routine that somebody else made, also allowed me to add a signature to the template that I was using. Both of these things have made phpWord successful in my testing. Thanks.