日期:2014-05-17  浏览次数:20465 次

【PHPWord】从模板创建Word

源文件

生成


require_once 'PHPWord.php';

$PHPWord = new PHPWord();

$document = $PHPWord->loadTemplate('Template.docx');

$document->setValue('Value1','Sun');
$document->setValue('Value2','SNK');
$document->setValue('Value3','MArs');
$document->setValue('Value4','Earth');
$document->setValue('Value5','Uranus');
$document->setValue('Value6','Pluto');
$document->setValue('Value7','Neptun');
$document->setValue('Value8','Mercury');
$document->setValue('Value9','Jupiter');
$document->setValue('Value10','Plutos');

$document->setValue('weekday',date('1'));
$document->setValue('time',date('H:i'));

//保存文件

$document->save('FromTemplate.docx');