> For the complete documentation index, see [llms.txt](https://xlswriter-docs.viest.me/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xlswriter-docs.viest.me/english/cell/insert-comment.md).

# Insert comment

## **Function Prototype**

```php
insertComment(int $row, int $column, string $text): self

insertCommentOpt(int $row, int $column, string $text, array $options): self

showComment(): self
```

### **int $row**

> cell row

### **int $column**

> cell column

### **string $text**

> comment text

### **array $options**

> Optional extended comment settings. All keys are optional:
>
> * `author` *string* — comment author
> * `font_name` *string* — font name
> * `font_size` *double* — font size
> * `color` *int* — background color (`0xRRGGBB` or a `Format::COLOR_*` constant)
> * `x_offset` *int* — horizontal pixel offset
> * `y_offset` *int* — vertical pixel offset
> * `x_scale` *double* — horizontal scale factor
> * `y_scale` *double* — vertical scale factor
> * `width` *double* — box width in pixels
> * `height` *double* — box height in pixels
> * `visible` *int* — comment display mode. Prefer the class constants below over raw integers:
>   * `Excel::COMMENT_DISPLAY_DEFAULT` — follow the workbook-wide default
>   * `Excel::COMMENT_DISPLAY_HIDDEN` — only shown on hover
>   * `Excel::COMMENT_DISPLAY_VISIBLE` — always pinned open
> * `start_row` *int* — anchor row of the box
> * `start_col` *int* — anchor column of the box

`showComment()` toggles the workbook-wide "show all comments" flag. Call it once to make every comment visible by default.

## Example

```php
$config = [
    'path' => './tests'
];

$excel = new \Vtiful\Kernel\Excel($config);

$file = $excel->fileName('tutorial.xlsx')
    ->header(['name', 'score']);

$file->insertText(1, 0, 'viest')
     ->insertText(1, 1, 99)
     ->insertComment(1, 1, 'Almost a perfect score!')
     ->insertCommentOpt(1, 0, 'Project owner', [
         'author'    => 'admin',
         'font_name' => 'Arial',
         'font_size' => 10,
         'color'     => \Vtiful\Kernel\Format::COLOR_YELLOW,
         'width'     => 200,
         'height'    => 80,
         'visible'   => \Vtiful\Kernel\Excel::COMMENT_DISPLAY_VISIBLE,
     ])
     ->showComment()
     ->output();
```
