【发布时间】:2018-06-06 19:44:29
【问题描述】:
我在 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);
【问题讨论】:
-
看起来borderStyle定义确实只影响单元格,并且似乎总是应用最小尺寸(当您增加值时它会按预期工作)。我不确定“无边框表格”的确切目标是什么,但产生看似“无边框”表格样式的一种方法是设置边框颜色以匹配您的背景颜色(可能是白色)。