PHP Word更改字段值

时间:2018-06-07 06:15:12

标签: php forms phpword

我试图在docx中写表格中的数据。

require_once '/tests/bootstrap.php';
if (isset($_POST['firstDoc']))
{
     $templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor('SP41_P5.docx');
     $templateProcessor->setValue('The object name (part 1)', $_POST['Theobjectname(part1)']);
     $templateProcessor->setValue('The object name (part 2)', $_POST['Theobjectname(part2)']);
     $templateProcessor->setValue('The object name (part 3)', $_POST['Theobjectname(part3)']);
     $templateProcessor->setValue('The system name', $_POST['Thesystemname']);
     $templateProcessor->setValue('The document designation', $_POST['Thedocumentdesignation']);
     $templateProcessor->setValue('The project code', $_POST['Theprojectcode']);
     $templateProcessor->setValue('The document code', $_POST['Thedocumentcode']);
     $templateProcessor->setValue('The system identity code', $_POST['Thesystemidentitycode']);
     $templateProcessor->saveAs('OUT_SP41_P5.docx');
}

此代码有效,但是,例如,如果对象名称(第1部分)的值在Word' s字段中,则它将跳过该值。 如何使字段中的值也改变?

0 个答案:

没有答案
相关问题