addSvg

addSvg

BASIC / ADVANCED / PREMIUM

Inserts an SVG into the Excel spreadsheet.

Description
public addSvg($svg, $position, $options = array())

You may use this method to insert an SVG content, as file or string, into the Excel spreadsheet.

To keep compatibility with XLSX readers not compatible with SVG images, a PNG image with the same content is added too in the spreadsheet.

Parameters

svg

File path or SVG content.

position

Cell position in the active sheet: A1, C3, AB7...

options

Key Type Description
colOffset array
  • 'from' (int) column size offset from.
  • 'to' (int) column size offset to.
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:
  • 'oneCell' (default) : move but don't size with cells.
  • 'twoCell' : move and size with cells.
  • 'absolute' : don't move or size with cells.
name string Sets a name value.
rowOffset array
  • 'from' (int) row size offset from.
  • 'to' (int) row size offset to.
rowSize int Number of rows used by the image.
Exceptions

ImageMagick extension is not enabled.

Code samples

Example #1

The resulting XLSX looks like:

Release notes
  • phpxlsx 2.0:
    • new method.