addComment

addComment

BASIC / ADVANCED / PREMIUM

Adds comments into the Excel spreadsheet.

Description
public addComment($contents, $position, $options = array())

This method allows adding a comment to a cell position.

The default base template include phpxlsx as default comment author.

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.
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...

options

Key Type Description
author string Author name.
replace bool If true replaces existing comment in the same position. Default as true.
Exceptions

Author doesn't exist. The author must exist in the sheet.

Code samples

Example #1

The resulting XLSX looks like:

Release notes
  • phpxlsx 2.5:
    • new method.