我正在使用 PHPWord... 我在文档的上部创建一个表格,然后在文档的中间部分创建我的第二个表格。现在发生的事情是两个表合并......是否有一个结束标记,如 html 中的结束标记表?或者使用 PHPWord 创建新表的最佳方法是什么?蒂亚:D
问问题
3661 次
1 回答
4
只需在两个表格之间添加一个空段落
$section->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");
于 2013-06-25T08:49:08.063 回答