How to add list to the loaded template in phpword

Viewed 2312

I used PHPword to create a word document in my web application but I coud not implement list. I used the following code:

$PHPWord = new PHPWord();
$temp = $PHPWord->loadTemplate('temp.docx');
$section = $PHPWord->createSection();
$section->addListItem('List Item 1', 0);
$section->addTextBreak(1);
$temp->setValue('Value1', $section);
$temp->save('list.docx');

This code is not working. I managed to create a list in a new document but I could not add the list to the template (I could not assign a list to the specific value). How can I add the list?

1 Answers
Related