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 = $phpWord->addSection();        
            $fontStyle = array('size' => 14, 'name' => 'Bookman Old Style'); 
            //$section->addListItem($text, [$depth], [$fontStyle], [$listStyle], [$paragraphStyle]);
            $section->addListItem('List item 1',0,$fontStyle,$fontStyle,$fontStyle);
            $section->addListItem('List item 2',0,$fontStyle,$fontStyle,$fontStyle);
            foreach ($phpWord->getSections() as $section) {// cue from https://stackoverflow.com/questions/52621939/how-to-create-a-word-document-with-all-the-content-of-several-others-with-phpwor
                //$phpWord->addExistingSection($section);            $this->templateProcessor->setComplexBlock ('VAR_4_SECTION', $section);// cue from https://phpword.readthedocs.io/en/latest/templates-processing.html#setcomplexblock
    
    - Pros : Simplest method
    - Cons: Modification to core feature, Font of bullet is different
  • templateProcessor->cloneBlock & templateProcessor->removeBlock Methods
  • Pros : Syncs with intention of PHPword
  • Cons : Issues with PHP 7.2(click) , so need to edit core code PhpOffice\PhpWord\TemplateProcessor
  • Bringing the effect with 2 column Tables.
    There are 2 ways to do it.

  • Extracting xml (Click to see code)
  • TemplateProcessor->setComplexBlock(Click to see code)
  • Prose and Cons:

  • Pros: No need to alter core code
  • Cons: More work needed, Not real ordered list.
  • Recent Comments

    Archives

  • July 2025
  • June 2025
  • May 2025
  • November 2024
  • July 2024
  • February 2024
  • January 2024
  • December 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • October 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • September 2021
  • August 2021
  • May 2021
  • April 2021
  • March 2021
  • Categories

  • AI Tools
  • Android Studio
  • Artificial Intelligence(AI)
  • bootstrap
  • Chrome
  • Commenting
  • facebook
  • FFMPEG
  • Firebase
  • Firefox
  • FPDF & FPDI
  • google
  • Google Apps
  • Google Sheets
  • HACKS
  • ImageMagick
  • Incorporation
  • IT Solutions Company
  • Js Hacks
  • JS Libraries
  • JS Tree
  • Linux
  • Material Design
  • Miscellaneous(PHP)
  • nodepad++
  • PDF Parser
  • PHP Libraries
  • PHP Word
  • PHPStorm
  • plugins
  • ReactJS
  • Responsive CSS Frameworks
  • Software Legal
  • Software Testing
  • Standardized Coding
  • Steps for setting up website
  • Ubuntu
  • Uncategorized
  • VS Code
  • Wordpress
  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
  •