Forum


Replies: 1   Views: 2378
Styling individual table cells
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 dgray  · 02-08-2019 - 13:39

Last question.

 

I'm very pleased with phpdocx and will probably be purchasing a license once management have seen the results. The only things I'm now struggling with are:

- making text effects (bold or italic) in individual cells using the addTable function.

 - adding Headings (addHeading()) inside tables.

 - I have set table column widths to a fixed size (columnWidths' => array(5000,1900,5000)) however the column widths printed are variable dependent on the content. I need them to be fixed.

I need to get this working to complete the demo that I'm currently doing. I have seen posts about using the addText() function - how would that work in table contents?

Note that I can achieve this with just HTML, but I need to use the cantSplit and tableHeader properties of addTable()

 

 

Posted by admin  · 02-08-2019 - 17:22

Hello,

You can add almost any content into cells using WordFragments (text with styles, lists, charts, images, HTML...), we recommend you to check the samples included in the package (core/addTable folder) and the samples available on https://www.phpdocx.com/api-documentation/word-content/add-table-Word-document-with-PHP (example #2). About WordFragments, please check the documentation available on https://www.phpdocx.com/documentation/practical/wordfragments-and-wordml. WordFragments are one of the most powerful features available in phpdocx.

About the table width, by default MS Word handles the width. To change this, you just need to set 'tableLayout' as 'fixed' when using addTable or use a custom table style. On https://www.phpdocx.com/api-documentation/word-content/add-table-Word-document-with-PHP you can read more information about this and other options available in the method.

Regards.