# 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();
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://xlswriter-docs.viest.me/english/cell/insert-comment.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
