L
L
lzy2018-12-26 14:34:59
Yii
lzy, 2018-12-26 14:34:59

How to create a Word document from a template?

I use PHP Word, I need to upload a word document according to a specific template. https://blog.mayflower.de/6699-phpword-create-docu... found an example of using my own template on the site, code

$templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('Template.docx');
 
$templateProcessor->setValue('date', date("d-m-Y"));
$templateProcessor->setValue('name', 'John Doe');
$templateProcessor->setValue(
    ['city', 'street'],
    ['Sunnydale, 54321 Wisconsin', '123 International Lane']);
 
$templateProcessor->saveAs('MyWordFile.docx');

But it gives an error No such file or directory, where should I put the Template file, in which folder? Gives an error No such file or directory

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2018-12-26
@AlexMaxTM

Write the full path to the template
\path\to\tamlates\Template.docx

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question