PHPWord icon indicating copy to clipboard operation
PHPWord copied to clipboard

Can not clone row, template variable not found or variable contains markup

Open cristianpark opened this issue 11 years ago • 5 comments

Hi guys, I have this template [1] with two tables, I have no problem with the second table, I have code like this:

$plantilla->cloneRow('numeroCDP', 4);
--Values
$plantilla->setValue('numeroCDP#1', 1);
...
$plantilla->setValue('numeroCDP#4', 4);

For the first table I have the following code (dinamic created values):

$plantilla->cloneRow($campoClonar->getAlias(), $totalFilas);

for($f=1; $f<=$totalRows; $f++){
    foreach($fields as $field){
        $plantilla->setValue($field->getAlias().'#'.$f, utf8_encode(strip_tags('The value')));
     }//End foreach ($fields)
}

And I have this error: Can not clone row, template variable not found or variable contains markup

Do you know what can be wrong with my code or my template??

Thanks in advance

[1] http://www.mediafire.com/view/c6wbpc77uk1obs9/PlantillaElvira.docx


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

cristianpark avatar Jun 11 '14 22:06 cristianpark

One of the common source of problem with template is that the variable is separated into multiple run. Please try to "clear all styles" in the variable part of your template that causes the problem. I'll find time (probably tonight) to look at your template xml file.

ivanlanin avatar Jun 12 '14 03:06 ivanlanin

Can you check the value of $campoClonar->getAlias()? It should be equal to tablaCantidad. I've been able to clone the row with the following code:

$document->cloneRow('tablaCantidad', 2);
$document->setValue('tablaCantidad#1', 'A');
$document->setValue('tablaCantidad#2', 'B');

ivanlanin avatar Jun 13 '14 11:06 ivanlanin

I've had issues today where Word's spellchecker was causing the tags in the documents.xml to change the tag. The solution I've found for this was ignoring the spell checker by right clicking on the word and "ignore all".

OAFCROB avatar Jun 30 '15 10:06 OAFCROB

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue for you, please try to help by debugging it further and sharing your results. Thank you for your contributions.

github-actions[bot] avatar Nov 18 '22 02:11 github-actions[bot]

I think cloneRow reported an error because the format of the table used in the template creation process was wrong, so that when copying ${data}, the process did not recognize that it was a table.

yuyi1122 avatar Jun 17 '24 02:06 yuyi1122