编程爱好者之家

PHPWord生成word实现table合并(colspan和rowspan)

2019-12-15 74

PHPWord rowspan的使用:

$table = $section->addTable();
$table->addRow();
$table->addCell(100,array('vMerge' => 'restart'))->addText('1');
$table->addCell(100)->addText('2');
$table->addRow();
$table->addCell(100,array('vMerge' => 'fusion'));
$table->addCell(100)->addText('3');

 生成的word效果如下截图:

 image.png

PHPWord colspan的使用:

$table->addRow();
$styleCell=array('gridSpan' => 2);
$table->addCell(200, $styleCell)->addText('编程爱好者之家');
$table->addCell(100)->addText('www.codelovers.cn');
$table->addRow();
$table->addCell(100)->addText('PHP');
$table->addCell(100)->addText('python');
$table->addCell(100)->addText('java');
$section->addTextBreak(10);

生成word效果图如下:

image.png


同类文章

您的赞赏是对小编最大的支持!