Forum


Replies: 2   Views: 4629
Different border style for nested table
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 wwu_ivv_wiwi  · 08-03-2015 - 21:11

I would like to create a table inside a table that has a different border style. At the moment the generated Document looks like this: http://cl.ly/image/2S1R370e0r3z What I try to achieve is this (created in MS Word): http://cl.ly/image/1V1K360D3y13 Please find the code for this working example below. How can I get to the desired result. I already tried to user 'borderSettings' => 'inside' for the nested table, but this setting seems to be ignored. Thank you! ########################################## $cw = explode(';', str_repeat('550;', 16)); array_pop($cw); $ms_options = array( 'columnWidths' => array(500, 1200, 4500, 400, 1500, 1500), 'tableStyle' => 'TableGridPHPDOCX', 'borderSettings' => 'inside', 'tableAlign' => 'center', 'cellMargin' => 75, 'textProperties' => array( 'font' => 'Meta', 'vAlign' => 'center', ) ); $ms_1 = array( 'colspan' => 1, 'vAlign' => 'center', 'value' => 'No'); $ms_2 = array( 'colspan' => 1, 'vAlign' => 'center', 'value' => 'Type'); $ms_3 = array( 'colspan' => 1, 'vAlign' => 'center', 'value' => 'Example'); $ms_4 = array( 'colspan' => 1, 'vAlign' => 'center', 'value' => 'Example'); $ms_5 = array( 'colspan' => 1, 'vAlign' => 'center', 'value' =>'Example'); $ms_6 = array( 'colspan' => 1, 'vAlign' => 'center', 'value' => 'Example'); $ms_values[] = array($ms_1, $ms_2, $ms_3, $ms_4, $ms_5, $ms_6); $ms_values[] = array( '1', 'ABC', 'asdasd asd', '3', 'asdasd', 'Test123', ); $ms_values[] = array( '1', 'ABC', 'asdasd asd', '3', 'asdasd', 'Test123', ); $c6_1 = array( 'colspan' => 1, 'vAlign' => 'center', 'value' => '3'); $tf = new \Phpdocx\Elements\WordFragment($docx); $text = array( array('text' => 'Some Information:', 'bold' => true,'font' => 'Meta', 'lineBreak' => 'after') ); $tf->addText($text); $tf->addTable($ms_values, $ms_options); $c6_2 = array( 'colspan' => 15, 'value' => $tf); $values[] = array($c6_1, $c6_2); //A4 width: 11905 $options = array( 'columnWidths' => $cw, 'border' => 'single', 'borderWidth' => 4, 'borderColor' => '000000', 'cellMargin' => array('top' => 100,'right' => 100,'bottom' => 150, 'left' => 100), 'cellSpacing' => 20, 'textProperties' => array( 'font' => 'Meta', 'vAlign' => 'center', ) ); $docx->addTable($values, $options);

Posted by admin  · 09-03-2015 - 08:36

Hello, You need the set the border* properties. For example: $valuesTable = array( array( array( 'value' => 11, 'borderLeft' => 'nil', 'borderTop' => 'nil', 'borderBottom' => 'nil', ), array( 'value' => 12, 'borderTop' => 'nil', 'borderBottom' => 'nil', ), array( 'value' => 13, 'borderTop' => 'nil', 'borderBottom' => 'nil', ), array( 'value' => 14, 'borderTop' => 'nil', 'borderRight' => 'nil', 'borderBottom' => 'nil', ), ), ); $paramsTable = array( 'border' => 'single', 'tableAlign' => 'center', 'borderWidth' => 10, 'borderColor' => 'B70000', 'textProperties' => array('bold' => true, 'font' => 'Algerian', 'fontSize' => 18), ); $docx->addTable($valuesTable, $paramsTable); Regards.

Posted by wwu_ivv_wiwi  · 10-03-2015 - 20:44

ok this is not a very elegant solution, but I got it to work, thanks!