Dimitur Dimitrov
Dimitur Dimitrov

Reputation: 51

Cannot export docx which contains html paragraph tag via PHPWord library

I'm using this library

Code example:

<?php

use \PhpOffice\PhpWord\PhpWord;

$phpWord = new PhpWord();
$section = $phpWord->addSection();
$section->addText('test');
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
$objWriter->save('Appdividend.docx');
return response()->download(public_path('Appdividend.docx'));

It works fine and returns docx file with "test" text, but when replace this row :

$section->addText('test'); with this one

$section->addText('<p>test</p>'); the docx document is empty.

Upvotes: 0

Views: 181

Answers (1)

framesecond
framesecond

Reputation: 79

You can't just write the HTML formatted text into a DOCX field.

Upvotes: 1

Related Questions