Forum


Replies: 3   Views: 3895
Table in template
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 kpholland  · 26-02-2016 - 10:50

I have one array that fills our table in our Word Template. That works great (see previous topic :) )  Is it possible to give the first row different table ($paramsTable) settings?

I have tried to split the header and the content in two tables but then there is a hole between the tables in the Word template..

$Array_Table_Value[1]['JNR']    = 'Year';
$Array_Table_Value[1]['NAAM']   = 'Name';

$Array_Table_Value[2]['JNR']    = 2016;
$Array_Table_Value[2]['NAAM']   = 'Pino';

$Array_Table_Value[3]['JNR']    = 2016;
$Array_Table_Value[3]['NAAM']   = 'Elmo';

$Array_Table_Value[4]['JNR']    = 2016;
$Array_Table_Value[4]['NAAM']   = 'Bird';
 

$paramsTable = array(
    'border' => 'single',
    'tableAlign' => 'center',
    'borderWidth' => 10,
//    'borderColor' => 'B70000',
    'textProperties' => array('bold' => false, 'font' => 'Verdana', 'fontSize' => 10),
);

Posted by admin  · 29-02-2016 - 07:43

Hello,

You can set cell properties through the $tableData properties:

     *      'value' (mixed) a string or WordFragment
     *      'rowspan' (int)
     *      'colspan' (int)
     *      'width' (int) in twentieths of a point
     *      'border' (nil, single, double, dashed, threeDEngrave, threeDEmboss, outset, inset, ...)
     *          this value can be override for each side with 'borderTop', 'borderRight', 'borderBottom' and 'borderLeft'
     *      'borderColor' (ffffff, ff0000)
     *          this value can be override for each side with 'borderTopColor', 'borderRightColor', 'borderBottomColor' and 'borderLeftColor'
     *      'borderSpacing' (0, 1, 2...)
     *          this value can be override for each side with 'borderTopSpacing', 'borderRightSpacing', 'borderBottomSpacing' and 'borderLeftSpacing'
     *      'borderWidth' (10, 11...) in eights of a point
     *          this value can be override for each side with 'borderTopWidth', 'borderRightWidth', 'borderBottomWidth' and 'borderLeftWidth'
     *      'background_color' (ffffff, ff0000)
     *      'noWrap' (boolean)
     *      'cellMargin' (mixed) an integer value or an array:
     *          'top' (int) in twentieths of a point
     *          'right' (int) in twentieths of a point
     *          'bottom' (int) in twentieths of a point
     *          'left' (int) in twentieths of a point
     *      'textDirection' (string) available values are: tbRl and btLr
     *      'fitText' (boolean) if true fits the text to the size of the cell
     *      'vAlign' (string) vertical align of text: top, center, both or bottom

And you also can use WordFragments to format the cell content or even use a custom template whit a table that you replace its content and then merge into the document.

Regards.

Posted by kpholland  · 04-03-2016 - 10:53

I do not understand your answer...I did find how to set table settings.But i ony want to set the setting for the first row and the rows after the first row i want to leave default

Posted by admin  · 04-03-2016 - 14:25

Hello,

UPDATE: The createTableStyle method includes a lot of optiones to apply styles to tables, such as firstRowStyle to apply style only to the first row.

There's no option to format only the first row, but you can set some settings for each cell of the first row using WordFragments.

For complex tables we recommend you to use embedHtml, you can read some samples about tables on http://www.phpdocx.com/documentation/introduction/html-to-word-PHP. Using HTML you can customize the first row of tables.

Regards.