Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vandan's avatar
Level 13

how to add comments in maatwesite excel package

hi guys

how can i add excel tooltips in maatwebsite to export excel sheet help me

0 likes
3 replies
vandan's avatar
Level 13

Any of know how to export with columns comments using excel maatwebsite pacakge

vandan's avatar
Level 13

i search on google and try it but no comments export in excel file

here is my Userexport.php

public function sheets(): array
	{
    	$event->sheet->getDelegate()->getComment('A1')->getText()->createTextRun('Your comment:');
	}

Controller file

public function export() 
	{
    	return Excel::download(new UsersExport, 'users.xlsx');
	}

simple file export no comments are exported into excel sheet

vandan's avatar
Level 13

i can set comments static but now problem is that how to suppose i have lots of records in database so how to comments in all data using loop

here is my function

public static function afterSheet(AfterSheet $event)
	{
    	$event->sheet->getDelegate()->getComment('B2')->getText()->createTextRun('User Name');
    	$event->sheet->getDelegate()->getComment('C2')->getText()->createTextRun('User Email');
	}

actually cell B2 and C2 but when database add data into excel file automatice add comments particular cell

how can i make it?

Please or to participate in this conversation.