2012-10-05 71 views
2

我正在使用PHPWord ...我在文檔的上半部分創建一個表格,然後在文檔的中間部分創建我的第二個表格。現在最新發生的是這兩個表合併...是否有一個結束標記,如表格的html中的關閉標記?或者什麼應該是使用PHPWord創建新表的最佳方式? TIA:dPHPWord創建一個多表

回答

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->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");