我已经在phpword文件中添加了一个表,但似乎无法更改表的边框。我读到borderSize是一个特定于单元的设置,但即使是这样也没有变化。边界根本不会改变。我在堆栈溢出问题上尝试了很多方法,但似乎找不到解决方案。以前有没有人遇到过类似的问题?
$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);
发布于 2019-01-25 17:41:59
为每个单元格的每个边框设置边框颜色和边框大小:
$styleCell =
[
'borderColor' =>'ff0000',
'borderSize' => 6,
];
$table->addCell(2000, $styleCell);
或
$styleCell =
[
'borderTopColor' =>'ff0000',
'borderTopSize' => 6,
'borderRightColor' =>'ff0000',
'borderRightSize' => 6,
'borderBottomColor' =>'ff0000',
'borderBottomSize' => 6,
'borderLeftColor' =>'ff0000',
'borderLeftSize' => 6,
];
$table->addCell(2000, $styleCell);
https://stackoverflow.com/questions/50728370
复制相似问题