【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'));<span style="color:#ff0000;">//保存文件$document->save('FromTemplate.docx');</span>