我正在尝试用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文档,似乎我缺少了一些东西。
答案 0 :(得分:0)
表格网格不能仅通过播放单元格宽度来实现跨越多个列或行的单元格;需要明确定义跨越多列和多行的单元格。
您可以在How to make the table in word using PHPWord which includes multiple rowspan and colspan?
处找到另一个类似的带有答案示例的问题。