-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Hi,
I'm new to PhpWord and am using this awesome library for one project. I need to make a template file and replace some info with data from user input. I use TemplateProcessor and the code looks something like so:
templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor($template_file); $templateProcessor->setValue('firstname', $data['firstname']); $templateProcessor->setValue('lastname', $data['lastname']); $templateProcessor->saveAs('/tmp/filled.docx');
This, however, doesn't work as I expected. The Word file is a very simple file with a couple of lines inform of Key: Value. For example:
First name: firstname
Last name: lastname
The keys need to be replaced with real data from user input. There are a couple of things that I need your help:
- What should be the first parameter in setValue(). I suppose it's a word variable, right or can it be a piece of text?
- I'm using Word for Mac, how can I add a variable that can be used in setValue()? I can't seem to find any ways of doing that. On Mac, it has only things like AutoText, Field. I tried them all but none works.
Thank you!