【发布时间】:2012-10-05 08:41:25
【问题描述】:
我正在使用 PHPWord... 我在文档的上部创建一个表格,然后在文档的中间部分创建我的第二个表格。现在发生的事情是两个表合并......是否有一个结束标签,比如 html 中的结束标签。或者使用 PHPWord 创建新表的最佳方法是什么? 蒂亚:D
【问题讨论】:
我正在使用 PHPWord... 我在文档的上部创建一个表格,然后在文档的中间部分创建我的第二个表格。现在发生的事情是两个表合并......是否有一个结束标签,比如 html 中的结束标签。或者使用 PHPWord 创建新表的最佳方法是什么? 蒂亚:D
【问题讨论】:
只需在两个表格之间添加一个空段落
$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");
【讨论】: