I has create table using phpword. I want set border for specific cell only. For testing, I have create two array style, border=6
and border=0
. I set style1 to cell 1 and style2 to cell 2. In word file generated, both cell has border.
<?php
include_once '../vendor/autoload.php';
use PhpOffice\PhpWord\Element\Table;
use PhpOffice\PhpWord\TemplateProcessor;
use PhpOffice\PhpWord\ComplexType\TblWidth;
$styleCell1 = array('borderColor' =>'black', 'borderSize' => 6)
$styleCell2 = array('borderColor' =>'black', 'borderSize' => 0);
$table = new Table();
$table->addRow();
$table->addCell(700,$styleCell1)->addText('cell 1');
$table->addCell(500,$styleCell2)->addText(cell 2);
$phpWord = new TemplateProcessor('phpWordTableTemplate.docx');
$phpWord->setComplexBlock('{table}', $table);
$phpWord->saveAs('template_with_table_output.docx');
?>
How to remove border in PhpWord table?
Can set border none to table cell only:
use PhpOffice\PhpWord\SimpleType\Border;
$styleCell2 = array('borderColor'=>'black', 'borderSize'=> 0, 'borderStyle' => Border::NONE);