1

I have a doc template which contains the following table:

input

and with php I fill the variable with this line:

$templateProcessor->setValues(array("{key1}" => 59, "{key2}" => 80));

The output I get is the following:

output

Note that key1 has been replaced twice, while key2 only in the text area and not inside the table. The problem seems to be related to the way the templateProcessor handles tables... Is there any way to make this work?

I also tried just with setValue, getting the same result

$templateProcessor->setValue("{key1}", 59);
$templateProcessor->setValue("{key2}", 80);
1
  • Have you looked in github.com/PHPOffice/PHPWord/issues to see if anyone raised something similar? I suspect on Stackoverflow you won't get the internals of PHPWord fixed, but you might if you raise a ticket with the project directly (or vote for an existing ticket about the same issue, if it exists). Commented Aug 19, 2024 at 14:37

1 Answer 1

0

The solution was to use a clearer syntax in the template, marking all placeholders with ${placeholder} instead of {placeholder}.

This allows a clean:

$templateProcessor->setValues(array("key1" => 59, "key2" => 80));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.