Laravel Excel 垂直居中对齐
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/51902003/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel Excel vertical align center
提问by Furya
How can I verticaly align center cells with laravel Excel ?
如何使用 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.
感谢您的帮助。
采纳答案by Rafael
According to Laravel Excel Documentation, it should be:
根据Laravel Excel Documentation,它应该是:
$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.
尝试作为测试,setAlignment('center')
根据它,行为应该相同但水平。如果这个有效,那么另一个应该肯定。