Laravel Excel vertical align center

Furya picture Furya · Aug 17, 2018 · Viewed 10.4k times · Source

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.

Answer

Rafael picture Rafael · Aug 17, 2018

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.