replaceVariableImage

replaceVariableImage

BASIC / ADVANCED / PREMIUM

Replaces placeholders within images with new images.

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

This method allows to replace placeholder images with new images.

The placeholder image should be tagged using the alternate text option of the Excel interface (this may depend on the Excel version).

Parameters

variables

Array with the names of the placeholder template image variables as keys and the image paths, base64 contents or streams that should replace them.

options

The possible keys and values of this array are:

Key Type Description
mime string Forces a mime (image/jpg, image/jpeg, image/png, image/gif).
target string sheets (default), headers, footers.
Exceptions

Image doesn't exist.

Code samples

Example #1

The resulting XLSX looks like:

Release notes
  • phpxlsx 2.5: stream and base64 as image source.
  • phpxlsx 2.0: supported drawingHF tags.
  • phpxlsx 1.0: new method.