我正在使用PHPWord ...我在文档的上半部分创建了一个表格,然后我在文档的中间部分创建了第二个表格。现在发生的事情是两个表合并...是否有一个结束标记,如表格的html中的关闭标记?或者什么应该是使用PHPWord创建新表的最佳方法? TIA:D
答案 0 :(得分:4)
只需在两个表之间添加一个空段
$本条> addText( “”);
include('includes/PHPWord.php');
include('includes/PHPWord/Writer/Word2007.php');
$word = new PHPWord();
$styleTable = array('borderColor'=>'006699',
'borderSize'=>6,
'cellMargin'=>50);
$styleFirstRow = array('bgColor'=>'66BBFF');
$word->addTableStyle('myTable', $styleTable, $styleFirstRow);
$word->setDefaultFontName('Tahoma');
$word->setDefaultFontSize(10);
$section = $word->createSection();
$table = $section->addTable();
$table->addRow(200);
$table->addCell(1200)->addText("Col 1");
$table->addCell(1200)->addText("Col 2");
$table->addCell(1200)->addText("Col 3");
$table->addCell(1200)->addText("Col 4");
$table->addCell(1200)->addText("Col 5");
$table->addRow(200);
$table->addCell(1200)->addText("Col 1");
$table->addCell(1200)->addText("Col 2");
$table->addCell(1200)->addText("Col 3");
$table->addCell(1200)->addText("Col 4");
$table->addCell(1200)->addText("Col 5");
$section->addText("");
$table = $section->addTable();
$table->addRow(200);
$table->addCell(1200)->addText("Col 1");
$table->addCell(1200)->addText("Col 2");
$table->addCell(1200)->addText("Col 3");
$table->addCell(1200)->addText("Col 4");
$table->addCell(1200)->addText("Col 5");
$table->addRow(200);
$table->addCell(1200)->addText("Col 1");
$table->addCell(1200)->addText("Col 2");
$table->addCell(1200)->addText("Col 3");
$table->addCell(1200)->addText("Col 4");
$table->addCell(1200)->addText("Col 5");
$objWriter = PHPWord_IOFactory::createWriter($word,'Word2007');
$objWriter->save("test.docx");