S
S
sawa42016-11-21 16:25:46
Laravel
sawa4, 2016-11-21 16:25:46

How phpword add html data laravel 5.2?

Hi guys!
I use phpword in Laravel 5.2, I can't add html tags to word.
Below in the $about variable is the text with html tags, how to insert it so that word-e has the appropriate formatting

$section->addText("1. ".mb_strtoupper(trans('persons.general'), 'UTF-8'), $fontbold, $pStyle);
$section->addText('Анкета - '.$fio(), $fontbold, $pStyle);
//... тут куча кода
$word->addTableStyle('general', $styleTable);
$table = $section->addTable('general');
//... тут куча кода
$table3->addRow();
$table3->addCell(5000, $cellColSpan2)->addText('Обо мне'));
$table3->addCell(5000, $cellColSpan2)->addText(isset($about) ? $about : ""); //в переменной $about текст с html тегами

$responseName = ''.$id.'.doc';
$writer = IOFactory::createWriter($word, 'Word2007');
$writer->save($responseName);
return Response::download($responseName);

Google found me something like this:
$phpWord = new \PhpOffice\PhpWord\PhpWord();
$section = $phpWord->addSection();
\PhpOffice\PhpWord\Shared\Html::addHtml($section, $html);

But I still do not understand how to use it in my case.
Maybe someone did something similar?
Guys share...
Really nobody faced such task!?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
BoShurik, 2016-11-22
@sawa4

HTMLOut of the box class doesn't always work as it should
Try this one: https://gist.github.com/BoShurik/f6f91582d14ebd02e...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question