简体   繁体   English

phpword表无边框

[英]PhpWord table no border

I've added a table to a phpword file but seem to be unable to change the border of the table. 我已经将表格添加到phpword文件中,但是似乎无法更改表格的边框。 I read that borderSize is a cell specific setting but even there no change. 我读到borderSize是特定于单元格的设置,但即使没有更改。 The border doesn't change at all. 边界完全不变。 I've tried numerous things here on stack overflow but can't seem to find the solution. 我在这里尝试了很多有关堆栈溢出的事情,但是似乎找不到解决方案。 Did anyone run into a similar problem before? 有人遇到过类似的问题吗?

$phpWord = \PhpOffice\PhpWord\IOFactory::load($file);
$styleTable = array('borderColor'=>'#CCC', 'borderSize'=> 2, 'cellMargin'=>50, 'valign'=>'center');
$styleFirstRow = array('bgColor'=>'#CCC', 'bold'=>true, 'size'=>11, 'valign'=>'center');
$styleCell = array('valign'=>'center');
$fontStyle = array('bold'=>false, 'align'=>'center', 'color'=>'ccc');

$phpWord->addTableStyle('myTable', $styleTable, $styleFirstRow);

$section = $phpWord->createSection();
$table = $section->addTable('myTable');

$table->addRow(900);
$table->addCell(2000, $styleCell)->addText('#SIG01_100_200#', $fontStyle);
$table->addCell(2000, $styleCell)->addText('#SIG02_100_200#', $fontStyle);

$xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord , 'PDF');
$xmlWriter->save($file_pdf);

Set border color and border size for every side of every cell: 为每个单元格的每一侧设置边框颜色和边框大小:

$styleCell =
[
    'borderColor' =>'ff0000',
    'borderSize' => 6,
];
$table->addCell(2000, $styleCell);

or 要么

$styleCell =
[
    'borderTopColor' =>'ff0000',
    'borderTopSize' => 6,
    'borderRightColor' =>'ff0000',
    'borderRightSize' => 6,
    'borderBottomColor' =>'ff0000',
    'borderBottomSize' => 6,
    'borderLeftColor' =>'ff0000',
    'borderLeftSize' => 6,
];
$table->addCell(2000, $styleCell);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM