我正在尝试用phpword创建一个表。然而,我正在为这个表的配置语法而挣扎。
下面是我的代码:
// Define table style arrays
$styleTable = array('borderSize'=>2, 'cellMargin'=>10);
$styleFirstRow = array('borderBottomSize'=>5, 'bgColor'=>'#D3D3D3');
// Define cell style arrays
$styleCell = array('valign'=>'center', 'bgColor'=>'#D3D3D3');
$styleCellBTLR = array('valign'=>'center');
// Define font style for first row
$fontStyle = array('bold'=>true, 'align'=>'center');
// Add table style
$wordTest->addTableStyle('CoverLine', $styleTable, $styleFirstRow);
// Add table
$table = $newSection->addTable('CoverLine');
// Add row
// $table->addRow(200);
// Add cells
// $table->addCell(10000, $styleCell)->addText('Employer Details ', $fontStyle);
//$table->addCell(1800)->addText($curriculum->curriculum_code);
$table->addRow(500);
$table->addCell(2200, $styleCell)->addText(' Code', $fontStyle);
$table->addCell(5000, $styleCell)->addText(' Title', $fontStyle);
$table->addRow(500);
$table->addCell(2200)->addText('', $fontStyle);
$table->addCell(5000)->addText('', $fontStyle);
$table->addRow(500);
$table->addCell(2200, $styleCell)->addText('', $fontStyle);
$table->addCell(1200, $styleCell)->addText(' Name', $fontStyle);
$table->addCell(2500, $styleCell)->addText(' Email', $fontStyle);
$table->addCell(2000, $styleCell)->addText(' Phone', $fontStyle);
$table->addCell(2000, $styleCell)->addText(' Logo', $fontStyle);
$table->addRow(600);
$table->addCell(700, $styleCell)->addText(' Development Quality Partner', $fontStyle);
$table->addCell(2000)->addText('');
$table->addCell(2000)->addText('');
$table->addCell(2000)->addText('');
$table->addCell(2000)->addText('');下图显示了我正在努力实现的目标:

我得到的东西和那个家伙太不一样了。请协助。我已经看过了phpword文档,好像遗漏了什么。
发布于 2018-07-05 06:58:23
表网格不只是使用单元格宽度来实现跨多列或多行的单元格;跨多列和多行的单元格需要显式定义。
您可以在How to make the table in word using PHPWord which includes multiple rowspan and colspan?找到另一个类似的问题,并提供答案示例。
https://stackoverflow.com/questions/51135895
复制相似问题