0

Learning Laravel, I face now Excel export.

Searching in the Intenet Laravel Excel (docs.laravel-excel.com) seems to be the better choice, but I'm findind it very difficult to style the sheets (colors, fonts, sizes, etc.)

I'm using global event listeners in my AppServiceProvider:

Sheet::listen(AfterSheet::class, function () {
        Sheet::macro('color_tab', function (Sheet $sheet, string $color) {
            $sheet->getDelegate()->getTabColor()->setRGB($color);
        });
});

And then I use it in my Export class:

...
public function __construct($color) {
    $this->color = $color;
}
...
use RegistersEventListeners;
...
public static function afterSheet(AfterSheet $event) {
    // this is an error because it's a static method!
    $event->sheet->color_tab($this->color);
}

The problem is that I have to color the tab whit the color given in the constructor, but I can't because all these method for styling the Excel are static.

How can I do this?

Is there another good library to export Excel? With an easier way of do the styling.

Thanks!

0

1 Answer 1

1

Finally I decided to use directly PhpSpreadSheet library whithout using wrapper Laravel Excel

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.