phpword

How to convert the html tag string to a word document using PHPWord?

自古美人都是妖i 提交于 2019-12-01 03:19:08
I have a HTML string and I want to print in the word document in same format and style as in the HTML. I am using the PHPWord When I give my HTML string say: $htmlval ="<h6><div style="text-align: center;"><b style=\\"font-size: x-large;\\">OFFER LETTER</b></div><font size=\\"3\\"><div style="text-align: center;"><span style=\\"font-size: medium;\\">(This goes as an email copy)</span></div>"; this is the HTML tags with break and div. to: $section->addText($htmlval); it prints all HTML tag but I want the content with the format specified in the HTML. In limited way its possible, but just only

PhpOffice\\PhpWord loadTemplate not rendering Word as it should

谁说胖子不能爱 提交于 2019-12-01 00:34:34
I have problem with rendering HTML tags when load template. I use HTMLtoOpenXML to render it, but in the end it is just plain code. I use this: $workDescription = $entity->getWorkDescription(); $workDescription = \HTMLtoOpenXML::getInstance()->fromHTML(str_replace("<br />","<br>", stripslashes($workDescription))); $workDescription = $this->replaceSpecialChar($workDescription); $phpWord = new \PhpOffice\PhpWord\PhpWord(); $document = $phpWord->loadTemplate($templatePath); $document->setValue('Description', $workDescription); $document->saveAs($file); And PhpWord load document, and set

HTML Reader from PHPWord does't work with tables?

非 Y 不嫁゛ 提交于 2019-11-30 21:25:52
When I use Html reader for my html for converting into docx, reader is cut off my table. PHP example: $reader = IOFactory::createReader('HTML'); $phpWord = $reader->load($this->getReportDir() . '/' . $fileName); $writer = IOFactory::createWriter($phpWord); $writer->save($this->getReportDir() . '/' . $fileName); Table example: <table> <tr> <td>№ п/п</td> <td>Общие показатели результатов прохождения проверочных листов</td> <td>Количество пройденных проверок</td> <td>% от общего количества пройденных проверок</td> </tr> </table> The current HTML class from PHPWord is very limited. The issue you

PhpOffice\PhpWord loadTemplate not rendering Word as it should

谁说我不能喝 提交于 2019-11-30 20:03:52
问题 I have problem with rendering HTML tags when load template. I use HTMLtoOpenXML to render it, but in the end it is just plain code. I use this: $workDescription = $entity->getWorkDescription(); $workDescription = \HTMLtoOpenXML::getInstance()->fromHTML(str_replace("<br />","<br>", stripslashes($workDescription))); $workDescription = $this->replaceSpecialChar($workDescription); $phpWord = new \PhpOffice\PhpWord\PhpWord(); $document = $phpWord->loadTemplate($templatePath); $document->setValue(

Auto download the file attachment using PHPWord

混江龙づ霸主 提交于 2019-11-29 09:40:49
I'm trying to use PHPWord to generate word documents. And the document can be generated successfully. But there is a problem where my generated word document will be saved on the server. How can I make it available to download straight away? Sample: $PHPWord = new PHPWord(); //Searching for values to replace $document = $PHPWord->loadTemplate('doc/Temp1.docx'); $document->setValue('Name', $Name); $document->setValue('No', $No); $document->save('php://output'); //it auto save into my 'doc' directory. How can i link to the header to download it as follows: header("Content-Disposition: attachment

How to add/set images on PHPOffice/PHPWord Template?

安稳与你 提交于 2019-11-28 07:44:22
I have an instance of a template on PHPWord. Is it possible to replace or add an image? Something like a setImageValue? $phpWord = new \PhpOffice\PhpWord\Template('a.docx'); $phpWord->setImageValue('IMAGE_PLACEHOLDER', 'a.jpg'); $phpWord->saveAs('b.docx'); Is something like this possible? Following code is the updated version of the one from TotPeRo (thanks again for your code!), for last phpOffice (0.11) that has evolved a little /** * Set a new image * * @param string $search * @param string $replace */ public function setImageValue($search, $replace) { // Sanity check if (!file_exists(

How to make the table in word using PHPWord which includes multiple rowspan and colspan?

蹲街弑〆低调 提交于 2019-11-28 04:07:55
问题 I have been learning the PHPWord for my academic project, and I also have the latest PHPWord library which supports "vMerge" for rowspan and "gridSpan" for colspan. I have been finding difficulty in creating one particular type of table structure as shown in the Image below. The problem is how to have same rowspan for '1','2' and '6' , in this case it is equal to 2. Any kind of help would be appreciated. edit-1 I have succeeded with basic rowspan and colspan, but I am finding difficulty with

How to add/set images on PHPOffice/PHPWord Template?

只愿长相守 提交于 2019-11-27 05:45:33
问题 I have an instance of a template on PHPWord. Is it possible to replace or add an image? Something like a setImageValue? $phpWord = new \PhpOffice\PhpWord\Template('a.docx'); $phpWord->setImageValue('IMAGE_PLACEHOLDER', 'a.jpg'); $phpWord->saveAs('b.docx'); Is something like this possible? 回答1: Following code is the updated version of the one from TotPeRo (thanks again for your code!), for last phpOffice (0.11) that has evolved a little /** * Set a new image * * @param string $search * @param