How to change styleTable on PHPWord?

2019-09-05 13:35发布

问题:

I have a problem with using the plugin phpword. I'm trying to change the style, but I can change the background of the cell and other parameters are considered by it.

$styleTable = array('borderColor'=>'006699',
                    'borderSize'=>6,
                    'cellMargin'=>50,
                    'valign'=>'center'
                   );
$styleFirstRow = array('bgColor'=>'6086B8',
                       'color'=>'white',
                       'bold'=>true,
                       'size'=>11,
                       'valign'=>'center'
                    );
$PHPWord->addTableStyle('myTable', $styleTable, $styleFirstRow);

If you want to look my code, he as here : http://pastebin.com/pw36n3aW

回答1:

I found where the problem was, it came from my settings that do not exist. Thank you for your time and help.

$styleFirstRow = array('bgColor'=>'#6086B8');
    $PHPWord->addTableStyle('myTable', $styleTable, $styleFirstRow);

    $styleCellFirstRow = array('valign'=>'center'); 
    $styleCell = array('valign'=>'center'); 

$styleTextFirstRow = array('name'=>'Lucida Sans Unicode', 'color'=>'white','size'=>12);
    $styleParagprapheFirstRow = array('align'=>'center');
    $table->addCell(2200, $styleCellFirstRow)->addText('Type du rapporteur', $styleTextFirstRow, $styleParagprapheFirstRow);


回答2:

I am not sure but you can try this

array('borderColor'=>array('rgb' => '006699'), .....

Do you have this line in your code

$table = $section->addTable('myOwnTableStyle');


回答3:

I think you need # to define color code

    $styleTable = array('borderColor'=>'#006699',....and so on