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.

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, stream or GdImage.

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 4.0:
    • GdImage as image source.
  • phpxlsx 2.5:
    • overwrite option renamed to replace.
    • stream and base64 as image source.
  • phpxlsx 1.0:
    • new method.