有没有办法用 Laravel Excel 3.1 冻结 excel 的第一行?

Is there a way to freeze the first row of the excel with Laravel Excel 3.1?

我在 Laravel 5.8 项目中使用 maatwebsite/excel 3.1。

我需要在导出 excel 时固定第一行。 version 2.1 as Freeze rows.

中已知的内容
Excel::create('Filename', function($excel) {
   $excel->sheet('Sheetname', function($sheet) {
       $sheet->freezeFirstColumn();
   });
})->export('xls');

从版本 3 开始,您应该使用 PhpSpreadsheet 的本地方法。

您可以尝试类似的方法:

class SomeExport implements ... // what you need to implement 
{
    // some other code
    
    public function registerEvents(): array
    {
        return [
            AfterSheet::class => function(AfterSheet $event) {
                $workSheet = $event->sheet->getDelegate();
                $workSheet->freezePane('A2'); // freezing here
            },
        ];
    }
}

您可以在此处找到更多信息:

升级:https://docs.laravel-excel.com/3.0/getting-started/upgrade.html

事件:https://docs.laravel-excel.com/3.1/imports/extending.html#events