I'm using Maatwebsite\Excel
to download excel file. When the file downloaded I want to make header row which specify the column heading, read only. After downloading no one can make any change in headers. Is it Possible to do make column name un-editable ? I looked for lock function , or protect function but couldn't find answer. please help.
i have registerEvents()
function where i'm specifying all the editing parts like ,
public function registerEvents(): array
{
return [
AfterSheet::class => function(AfterSheet $event) {
$event->sheet->getDelegate()->getStyle('A1:C1')->getFont()->setSize(16);
},
];
}
is there any function i can write here or anywhere!?
This solution worked for me for making header uneditable
$sheet->protectCells('A1:G1', 'PASSWORD');
$sheet->getStyle('A2:G10')->getProtection()->setLocked(\PhpOffice\PhpSpreadsheet\Style\Protection::PROTECTION_UNPROTECTED);
//A2:G10 is the range which can be editable
$sheet->getDelegate()->getProtection()->setSheet(true);