addTextBox

addTextBox

BASIC / ADVANCED / PREMIUM

Inserts a text box into the Excel spreadsheet.

Description
public addTextBox($contents, $position, $textBoxStyles = array(), $options = array())

This method inserts text boxes into the Excel spreadsheet.

Parameters

contents

This could be:

  • a string
  • an array with the following keys and values:
Key Type Description
text string The content to be inserted.
bold bool If true the content will be shown in bold characters.
color string Hexadecimal color value: 'FF0000', '000000'...
font string Font family: 'Arial', 'Calibri'...
fontSize int Font size in points.
highlight string Hexadecimal color value: 'FF0000', '000000'...
italic bool If true displays the content in italics.
strikethrough bool If true displays text in strikethrough.
subscript bool If true displays text in subscript.
superscript bool If true displays text in superscript.
underline string Underlines text: single, double.
  • a multidimensional array to add rich text contents

position

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

textBoxStyles

Key Type Description
align string left, center, right.
backgroundColor string Hexadecimal color value: 'FF0000', '000000'...
verticalAlign string top, middle, bottom.

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 text box.
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 text box.
Code samples

Example #1

The resulting XLSX looks like:

Example #2

The resulting XLSX looks like:

Release notes
  • phpxlsx 3.0:
    • new method.