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.
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. Hello,
Please run the included example Core/addTable/sample_2.php and check the output. It generates a table with three columns with different sizes.
And check too the samples_3.php in the same folder. Note the 'width' attribute in the col value, maybe you need to set it to avoid that the content increases the col size.
Regards.
It works perfectly! The fault was: I had to add the cell width property to the contain cell not to the header cell :)
Thanks!