PhpWord doesn't replace text

前端 未结 7 1787
闹比i
闹比i 2021-02-14 09:34

I have a docx file and I need to replace some text. This is done inside codeigniter framework; here is the code:

$this->load->library(\'word\');       
$te         


        
7条回答
  •  名媛妹妹
    2021-02-14 10:05

    It turns out that when you add text to a word file, it sometimes creates extra tags in the underlying xml file. So (pseudo code) ${NAME} can become ${NAME}

    Because of this, phpword can't find your needle.

    I'm using a mac with microsoft word and i can just cut all the contents of the word file and paste them again.

    Word will than recreate the underlying xml file in which ${NAME} is 1 tag instead of 3.

提交回复
热议问题