addBackgroundImage

addBackgroundImage

BASIC / ADVANCED / PREMIUM

Inserts a background image into the Excel spreadsheet.

Description
public addBackgroundImage($image, $options = array())

This method allows the insertion of a background image into the Excel spreadsheet.

The image can have the following extensions:

  • jpg or jpeg
  • png
  • gif

A background image does not behave exactly like a watermark but like a standard HTML background image: it tiles the entire background.

Parameters

image

Image file path, base64 or stream.

options

Key Type Description
replace bool If true replaces existing background images. Default as true.
Exceptions

Image doesn't exist.

Code samples

Example #1

The resulting XLSX looks like:

Release notes
  • phpxlsx 2.5:
    • overwrite option renamed to replace.
    • stream and base64 as image source.
  • phpxlsx 1.0:
    • new method.