replaceVariableText

replaceVariableText

BASIC / ADVANCED / PREMIUM

Replaces placeholder variables with text.

Description
public replaceVariableText($variables, $options = array())

This method replaces a set of placeholder variables with plain text.

Remember that the phpxlsx template variables should be surrounded by $ symbols or whatever symbol you have chosen via the setTemplateSymbol method.

Parameters

variables

Array with the names of the placeholder template variables as keys and the plain text that should replace them as values.

options

The possible keys and values of this array are:

Key Type Description
target string sheets (default) [sharedStrings XML content], headers, footers, comments.
Code samples

Example #1

The resulting XLSX looks like:

Release notes
  • phpxlsx 2.5:
    • applied htmlspecialchars to content values.
  • phpxlsx 1.0:
    • new method.