JSON API - replaceListVariable

replaceListVariable

PREMIUM TRIAL / ADVANCED

Replaces a single variable within a list by a list of items.

Note

You are reading the JSON API documentation. For the PHP API method please go to replaceListVariable.

JSON data
Key Description
variable The name of the variable that you want to replace by a list of items.
values An array of values (text strings or WordFragments) to replace the variable with.
firstMatch If the variable appears more than once within the Word document and firstMatch is set to true, phpdocx will only replace the first occurrence of the variable within the Word document.
target Possible values are: document (default), header, footer. This option sets the scope of the replacement procedure.
parseLineBreaks If true (default is false) parses the line breaks to include them in the Word document.
type inline (default) or block; used by WordFragment values.
wordFragmentOptions
  • stylesReplacementType (string): usePlaceholderStyles (keep placeholder styles, styles from the imported HTML are ignored), mixPlaceholderStyles (mix placeholder styles, placeholder styles overwrite HTML styles with the same name). Applies to the following styles: pPr, rPr
  • stylesReplacementTypeIgnore (object): styles to be ignored from the imported WordFragment. Use with mixPlaceholderStyles
  • stylesReplacementTypeOverwrite (boolean): if true, overwrite the placeholder styles don't set in stylesReplacementTypeIgnore. Use with mixPlaceholderStyles. Default as false
Code samples

Example #1

A template can be a local file, a Base64 string, or a remote file.

Release notes
  • phpdocx 18.0:
    • new action.