1.模板替换功能require_once 'PHPWord.php';
require_once 'PHPWord/IOFactory.php';
$PHPWord = new PHPWord();
$template = $PHPWord->loadTemplate('PHPWord/mb/test.docx');
$template->setValue('Name','你好,测试-123abc');//${Name}
$template->setValue('Street', 'Coming-Undone-Street 32');
$filename = 'PHPWord/mb/test_update.docx';
$template->save($filename);
2.直接创建表格$section = $PHPWord->createSection();
$styleTable = array('borderSize'=>6, 'borderColor'=>'000000', 'cellMargin'=>80);//表格样式
$fontStyle = array('bold'=>true, 'align'=>'center');//文字样式
$PHPWord->addTableStyle('table_1', $styleTable);//定义表格样式
$table = $section->addTable('table_1');
$table->addRow(400);
$table->addCell(2000)->addText('Cell 1',$fontStyle);
$table->addCell(2000)->addText('Cell 2',$fontStyle);
$table->addCell(2000)->addText('Cell 3',$fontStyle);
$table->addRow(1000);
$table->addCell(2000)->addText('Cell 4',$fontStyle);
$table->addCell(2000)->addText('Cell 5',$fontStyle);
$table->addCell(2000)->addText('Cell 6',$fontStyle);
$objWrite = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
$filename = 'PHPWord/mb/test_create.docx';
$objWrite->save($filename);
3.PHPWord插件文件及中文技术文档下载