lundi 6 août 2018

How can I change color a character laravel excel maatwebsite?

I get tutorial from here : https://laravel-excel.maatwebsite.nl/3.0/exports/extending.html

So I use version 3

My excel like this :

enter image description here

I want to change it to be like this :

enter image description here

So I want the character England change to red color and bold

I try like this :

namespace App\Exports;
...
use Maatwebsite\Excel\Concerns\WithEvents;
use Maatwebsite\Excel\Events\BeforeExport;
use Maatwebsite\Excel\Events\AfterSheet;

class SummaryExport implements FromView, WithEvents
{
    ...
    public function registerEvents(): array
    {
        return [
            AfterSheet::class    => function(AfterSheet $event) {
                $event->sheet->styleCells(
                    'B1:D1',
                    [
                        'borders' => [
                            'outline' => [
                                'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THICK,
                                'color' => ['argb' => 'EB2B02'],
                            ],
                        ]
                    ]
                );
            },
        ];
    }
}

There exist error like this :

Method Maatwebsite\Excel\Sheet::styleCells does not exist.

How can I solve this error?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire