Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Excel vertical align center

How can I verticaly align center cells with laravel Excel ?

My code :

$sheet->cells('A1:'.$column_end.$i, function ($cells) {
                $cells->setBackground('#d8d8d8');
                $cells->setFontWeight('bold');
                $cells->setValignment('middle');
            });

But it doesn't work, most of my cells are vertically align bottom.

Maybe it's not middle !

I tried 'center' but it didn't work neither. When I tried 'top' or 'bottom' it worked.

So why 'middle' or 'center' didn't ?

Thank for your help.

like image 720
Furya Avatar asked Aug 17 '18 19:08

Furya


1 Answers

According to Laravel Excel Documentation, it should be:

$cells->setValignment('center');

Like you mentioned...

Try as a test, the setAlignment('center'), according to it, the behavior should be the same but for horizontal. If this one works, then the other one should for sure.

like image 199
Rafael Avatar answered Sep 25 '22 09:09

Rafael