I'am migrating the laravel-excel package from 2.1 to 3.1.10 but i have many questions about this, the first is
/**
* @return array
* Version 3.1.10
*/
public function headings(): array
{
if ( sizeof($this->data) > 0 ) {
return array_keys($this->data[0]);
}
return [];
}
/**
* Version 2.1
*/
$sheet->row(1)->setAutoFilterByColumnAndRow(sizeof(array_values($data[0])) - 1,1);
You need to use the PhpSpreadsheet method in an extending event.
See extending documentation: https://docs.laravel-excel.com/3.1/exports/extending.html#events
And their docs about the auto filter functionality: https://phpspreadsheet.readthedocs.io/en/stable/topics/autofilters/
Thanks @patrickbrouwers it work's fine
I implement the interface WithEvents
And my registerEvents method was this:
/**
* @return array
*/
public function registerEvents(): array
{
return array(
AfterSheet::class => function(AfterSheet $event) {
$event->sheet->getDelegate()->setAutoFilter('A1:'.$event->sheet->getDelegate()->getHighestColumn().'1');
}
);
}
Thanks!
Most helpful comment
Thanks @patrickbrouwers it work's fine
I implement the interface WithEvents
And my registerEvents method was this:
Thanks!