Skip to content

TemplateProcessor, some values are not replaced (incl. debug) #548

Closed
@kaystrobach

Description

@kaystrobach

Given you have word document, with placeholders like ${some.object.path} any change in any place of the document can add some xml inside the brackets of the placeholder.

$template = new \PhpOffice\PhpWord\TemplateProcessor($this->templatePath);
throw  new \Exception(print_r($template->getVariables(), TRUE));

gives f.e. the following array

[0] => student.aktenzeichen
[1] => student.registraturSba
[2] => student.kontakt.vorname
[3] => st</w:t></w:r><w:r><w:t>u</w:t></w:r><w:r><w:t>dent.kontakt.nachname
[4] => student.kontakt.strasse
[5] => st</w:t></w:r><w:r><w:t>u</w:t></w:r><w:r><w:t>dent.kontakt.hausnummer
[6] => student.kontakt.plz
[7] => student.kontakt.ort
[8] => student.kontakt.nachname

3 and 5 will never be replaced as they are screwed up by word 😢 as i use getVariables to obtain real object pathes from my domain model i used strip_tags to transform it into a useable object path again.

But neither giving the broken values 3 / 5 to set values gives a successfull replacement ... any idea? my current approach is to digg deeper into the setValueForPart function and understand what you do with value cleaning ...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions