0

my phpword is not working and showing the following error

Fatal error: Uncaught Error: Call to a member function write() on null in phpoffice\PhpWord\Writer\Word2007.php:137 Stack trace: #0 test.php(45): PhpOffice\PhpWord\Writer\Word2007->save('HelloWorld.docx') #1 {main} thrown in phpoffice\PhpWord\Writer\Word2007.php on line 137

What is the solution for this error

My test code is below

    $phpWord = new \PhpOffice\PhpWord\PhpWord();
    $section = $phpWord->addSection();
    $section->addText('Hello World!');
    $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
    $xmlWriter->save('HelloWorld.docx');

`

I have tried changing permissions to 777 also. Still no luck

0 Answers0