PHPWord : Ordered list with TemplateProcessor

There are 3 ways to do it Each methods has its own Pros and Cons Crass way , Subclassing container class and using templateProcessor->setComplexBlock templateProcessor->setComplexBlock will give Error, Uncaught Error: Class ‘PhpOffice\PhpWord\Writer\Word2007\Element\Section’ not found. That is why container subclass is used namespace PhpOffice\PhpWord\Writer\Word2007\Element; class Section extends Container{} and then $phpWord = new \PhpOffice\PhpWord\PhpWord();//$this->templateProcessor->makeTable();//new \PhpOffice\PhpWord\PhpWord(); $section…

Finding and replacing text with PHPWord

Finding and replacing text with PHPWord PHPWord is only intented to create docx files. Anyhow, a docx file is simply a collection of xml files in a zip container. In general what you need to do is: Rename xxx.docx to Unzip to a temporary folder In temporary_folder_from_unzipped_doc/word read in document.xml which contains all…

PHP Word : Ordered Listings

$section->addListItem($text, [$depth], [$fontStyle], [$listStyle], [$paragraphStyle]);$listItemRun = $section->addListItemRun([$depth], [$listStyle], [$paragraphStyle]); Basic UsageaddListItem is used for creating lists that only contain plain text. addListItemRun is used for creating complex list items that contains texts with different style (some bold, other italics, etc) or other elements, e.g. images or links.

PHP Word : Template Processor

Two nice references An example for using phpWord Templates can be found here:

Getting Started with PHP Word

PHP Word documentation : The library for phpWord can be found here:¬† Sample codes : A nice tutorial to beginwith Install PHPWord via Composer (Composer is a Dependency Manager Tool for PHP. Like npm for Node.js) Add the below code to your composer.json file. In command prompt and type below to trigger the…