laravel 自动调整 Excel 列宽
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33270210/
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
Auto size Excel column width
提问by Cihan Küsmez
I'm using Laravel Excel pluginand have a problem with column widths. See the picture below, you can see the mistake:
我正在使用 Laravel Excel 插件并且在列宽方面有问题。看下图,可以看出错误:
Here is the correct view:
下面是正确的观点:
I tried $sheet->setAutoSize('true');
but it is not working.
我试过了,$sheet->setAutoSize('true');
但它不起作用。
How can I auto size column to the maximum content width of any cell in that column?
如何将列自动调整为该列中任何单元格的最大内容宽度?
回答by Eric V.
$sheet->getColumnDimension($column)->setAutoSize(true) ;
Duplicate of PHPExcel auto size column width