如何使用 laravel excel 将边框应用于特定单元格?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31646404/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 12:03:12  来源:igfitidea点击:

How can I apply borders to a specific cell with laravel excel?

phplaravellaravel-excel

提问by Ron van Asseldonk

I've been working with Laravel Excel for a few weeks now and I like it alot. But I can't apply borders to a specific cell.

我已经使用 Laravel Excel 几个星期了,我非常喜欢它。但我无法将边框应用于特定单元格。

This is my code:

这是我的代码:

$sheet->cell('A1', function($cell){
    $cell->setBorder('solid','solid','solid','solid');
});

Some background info about the cell 'A1':

关于单元格“A1”的一些背景信息:

  • It isn't a merged cell.
  • It does contain plain text only.
  • 它不是合并单元格。
  • 它只包含纯文本。

The sheet variable is a valid Excelsheet and I can add data to this.

sheet 变量是一个有效的 Excelsheet,我可以向其中添加数据。

Did I make a mistake somewhere or is this a known bug for Laravel Excel?

我是不是在某个地方犯了一个错误,或者这是 Laravel Excel 的一个已知错误?

Thanks for your time!

谢谢你的时间!

回答by shankshera

This is working for me

这对我有用

$sheet->cell('A1', function($cell){
    $cell->setBorder('thin','thin','thin','thin');
});

Please refer to this documentation, there is no solidoption. Yes, maybe there are some typos in that laravel-excelexample.

请参阅此文档,没有solid选项。是的,也许那个laravel-excel例子中有一些错别字。

回答by hhsadiq

Try this

尝试这个

$sheet->setBorder('A1', 'solid');