Skip to content

Conversation

@stxh
Copy link

@stxh stxh commented Sep 22, 2015

Support variable like cloneRow
in .docx

${BLOCK}
This is clone block ${No} Name=${Name} Value=${Value}
Please test it.
${/BLOCK}

in .php

$testData = array(
    array('Name'=>'Test Name 1', 'Value'=>123.45),
    array('Name'=>'Test Name 2', 'Value'=>223.45),
    array('Name'=>'Test Name 3', 'Value'=>323.45),
    array('Name'=>'Test Name End', 'Value'=>423.45),
);

$templateProcessor->cloneBlock('BLOCK', count($testData));
foreach ($testData as $n=>$v) {
    $templateProcessor->setValue('No#'.($n+1), $n+1);
    $templateProcessor->setValue('Name#'.($n+1), $v['Name']);
    $templateProcessor->setValue('Value#'.($n+1), $v['Value']);
}

Support variable like cloneRow
in .docx
```
${BLOCK}
This is clone block ${NO} Name=${Name} Value=${Value}
Please test it.
${/BLOCK}
```

in .php

···
$testData = array(
    array('Name'=>'Test Name 1', 'Value'=>123.45),
    array('Name'=>'Test Name 2', 'Value'=>223.45),
    array('Name'=>'Test Name 3', 'Value'=>323.45),
    array('Name'=>'Test Name End', 'Value'=>423.45),
);

foreach ($testData as $n=>$v) {
    $templateProcessor->setValue('Name#'.($n+1), $v['Name']);
    $templateProcessor->setValue('Value#'.($n+1), $v['Value']);
}
```
@armenmargaryan
Copy link

This was very useful update thanks

@troosan
Copy link
Contributor

troosan commented Dec 27, 2018

same as #817, which is cleaner and has tests

@troosan troosan closed this Dec 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants