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, streams or GdImage objets that should replace them.
options
The possible keys and values of this array are:
Key | Type | Description |
---|---|---|
alt | string | Alt value. |
colOffset | array |
|
colSize | int | Number of columns used by the image. |
descr | string | Descr value. |
mime | string | Forces a mime (image/jpg, image/jpeg, image/png, image/gif, image/bmp, image/webp). |
rowOffset | array |
|
rowSize | int | Number of rows used by the image. |
target | string | sheets (default), headers, footers. |
Exceptions
Image doesn't exist.
Release notes
- phpxlsx 4.0:
- alt, colOffset, colSize, descr, rowOffset and rowSize options.
- WebP images.
- GdImage as image source.
- phpxlsx 2.5:
- stream and base64 as image source.
- phpxlsx 2.0:
- supported drawingHF tags.
- phpxlsx 1.0:
- new method.