Read and replace contents in .docx (Word) file

前端 未结 4 613
渐次进展
渐次进展 2020-12-09 12:14

I need to replace content in some word documents based on User input. I am trying to read a template file (e.g. \"template.docx\"), and replace First name {fname}, Address {

4条回答
  •  醉酒成梦
    2020-12-09 12:37

    If you find simple solution you can use this library

    Example: This code will replace $search to $replace in $pathToDocx file

    $docx = new IRebega\DocxReplacer($pathToDocx);
    
    $docx->replaceText($search, $replace);
    

提交回复
热议问题