I'm currently trying to work with docx files using PHPWord library and its templating system. I have found and updated someones (cant remember the name, but its not important) path to this library that can work with tables (replicate its rows and then use standard setValue() from PHPWord on each of row).
If i create my own document, the data in xml is in normal structure, so the variable to be replaced ${variable} is in its own tag like this:
<w:tbl>
<w:tr>
...
${variable}
</w:tr>
</w:tbl>
I simplified the code, in actual code there is number of other tags descibing sizes, styles, etc.
My problem is i have to proccess documents from other people where i am prohibited to make big changes, I get a document where at some point they is a table with one blank row. I add the ${variable} variables and run it through PHPWord. Problem is, that it fails. After doing some research , I found out that the source XML looks like this:
....
...
${va
...
riab
...
le}
....
(again heavily simplified, but you get the picture)
This structure is a problem for me, because the function to clone rows uses strpos(), substr() and regular expressions to work and does not work with this structure (and I cant imagine elegant way to do it so).
So the question is - Does anybody know why docx does this and how to prevent him? I am looking for a solution via word, not PHP (I need current functions to work without much editing)