Laravel-excel: Add comment in cells Laravel Excel 3.1

Created on 4 Apr 2019  路  2Comments  路  Source: Maatwebsite/Laravel-Excel

Prerequisites

Versions

  • PHP version: 7.2
  • Laravel version: 5.8
  • Package version: 3.1

Description

Hello,
is there a way to add comments to a cell in Laravel Excel 3.1?

I am looking for it in github, maatwebsite & google but the only reference that I have found is https://github.com/Maatwebsite/Laravel-Excel/issues/618#issuecomment-164880255 but it doesn't work.

I am trying to add the comments in registerEvents() inside AfterSheet::class anon function.
I wrote the following statement:
$event->sheet->getDelegate()->getComment('A3')->getText()->createTextRun('Your comment:');

Thank you!

Most helpful comment

According to PhpSpreadsheet docs (https://phpspreadsheet.readthedocs.io/en/latest/topics/recipes/#add-a-comment-to-a-cell):

$event->sheet->getDelegate()->getComment('E11')->getText()->createTextRun('Your comment:')

AfterSheet event should be fine I think. Make sure you use xlsx.

All 2 comments

According to PhpSpreadsheet docs (https://phpspreadsheet.readthedocs.io/en/latest/topics/recipes/#add-a-comment-to-a-cell):

$event->sheet->getDelegate()->getComment('E11')->getText()->createTextRun('Your comment:')

AfterSheet event should be fine I think. Make sure you use xlsx.

Thank you so much @patrickbrouwers, the problem was I was using .xls and it doesn't work.
With xlsx it works like a charm!

Was this page helpful?
0 / 5 - 0 ratings