I am working with PHPWord... i create a table on the upper part of the document then i create my second table on the middle part of the document. Now whats happened is that the two table merge... is there a closing tag like a close tag in html for the table? or what should be the best way to create a new table using PHPWord? TIA :D
1 Answer
Just add an empty paragraph between the two tables
$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");