Forum


Replies: 2   Views: 3730
Set cols with when using addtable()
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 Sven May  · 18-02-2015 - 15:08

Hello! I create a table with column. I am using addTable() function to create my table. There is a header row then the content. In the left column there is an HTML content at right side normal text. I tri to fix my columns...first column would be 60% the second 40% wide. What I use: ...for header $table []= array( array('value'=>'1. col title - 60% wide', 'backgroundColor'=>'#E6E6E6', 'vAlign' => 'center', 'border'=>'single'), array('value'=>'2. col title - 40% wide', 'backgroundColor'=>'#E6E6E6', 'vAlign' => 'center', 'border'=>'single') ...for content: $wf = new WordFragment(); $descriptionContent = '

'.$_content['title'].'

'.$_content['description']; $wf->embedHTML($descriptionContent, array('wordStyles'=>array('.heading2'=>'Heading2'))); $table []= array( array('value'=>$wf, 'border'=>'single'), array('value'=>$_content['value'], 'border'=>'single') ); ...finally: $tableOptions = array('tableStyle'=>'Heading2', 'font'=>'Arial', 'conditionalFormatting'=>array('firstRow'=>true), 'textProperties'=>array('bold'=>true, 'textAlign'=>'center', 'font'=>'Arial', 'fontSize'=>10), 'tableLayout'=>'fixed', 'tableAlign' => 'center', 'columnWidths' => array(1500, 500)); $docx->addTable($table, $tableOptions, $trProperties); Unfortunately it is not work and I have no idea what I am doing worng.