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. |
| rotation | int | 60.000ths of a degree. |
| rowOffset | array |
|
| rowSize | int | Number of rows used by the image. |
| transparency | int | 0 to 100. |
Exceptions
Image doesn't exist.
Image format is not supported.
Release notes
- phpxlsx 5.5:
- rotation, transparency options.
- automatically apply htmlspecialchars to the hyperlink.
- extra check to preserve tag order when adding new drawing tags if legacy drawing tags already exist in the sheet.
- phpxlsx 5.0:
- improved working with legacy drawing contents.
- removed PHP Warnings when images to be added do not exist.
- 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.