addImage
addImage
BASIC / ADVANCED / PREMIUM
Inserts an image into the Excel spreadsheet.
Description
public addImage($image, $position, $options = array())
This method inserts images (jpg, png, gif, bmp or webp) into the Excel spreadsheet.
Image size is set using rowSize and colSize options. If these values are not set, the image size is set to 1 column and 1 row.
Parameters
image
Image file path, base64, stream or GdImage.
position
Cell position in the active sheet: A1, C3, AB7...
options
Key | Type | Description |
---|---|---|
colOffset | array |
|
colSize | int | Number of columns used by the image. |
descr | string | Descr value. |
dpi | int | Dots per inch. Autodetect if not set. |
editAs | string | Possible values are:
|
hyperlink | string | Hyperlink. |
mime | string | Forces a mime (image/jpg, image/jpeg, image/png, image/gif, image/bmp, image/webp). |
name | string | Sets a name value. |
rowOffset | array |
|
rowSize | int | Number of rows used by the image. |
Exceptions
Image doesn't exist.
Image format is not supported.
Release notes
- phpxlsx 4.0:
- WebP images.
- GdImage as image source.
- phpxlsx 2.5:
- stream and base64 as image source.
- phpxlsx 2.0:
- hyperlink option.
- phpxlsx 1.0:
- new method.