Replies: 1   Views: 849
Override table style
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by dev@ram  · 16-05-2017 - 13:58

I'm creating a table from a template with a custom table style. Sometimes I would like to override the text alignment of one of the columns in the table and make it left aligned instead of centered. I've tried to create a WordFragment for each cell in that column and set 'textAlign' => 'left' but this does not work.

Is there a way to do this?




Posted by admin  · 17-05-2017 - 08:35


When you create a table from scratch, you can set dynamic aligment. The sample Core/addTable/sample_4.php included in all package illustrates how to do it.

If you need to change the table align of a template, you can use three approaches:

  • Use the block type replacement to remove the whole paragraph and replace the placeholder by a new WordFragment with the new align if you are using a Basic, Advanced or Premium license.
  • Use DOCXPath to replace the cell content by a new WordFragment with the new alignment if you are using an Advanced or Premium license.
  • Use DOCXCustomizer if you are using a Premium license.