Reputation: 1063
I use version 3 of laravel maatwebsite-excel. I try to set the width of a column, to do that I use the PhpSpreadsheet native method in a AfterSheet event like this:
public function registerEvents(): array
{
return [
AfterSheet::class => function(AfterSheet $event) {
$event->sheet->getColumnDimension('D')->setWidth(32);
}
]
}
When i use: $event->sheet->getColumnDimension('D')->setVisible(false); it works, but setting the width doesn't have any effect.
Upvotes: 1
Views: 12080
Reputation: 1409
If you are exporting form view you can directly use
style="word-wrap:break-word"
Just make sure your Export class is not implementing ShouldAutoSize
Upvotes: 0
Reputation: 1063
Need to set column autosize to false
$event->sheet->getColumnDimension('D')->setAutoSize(false);
Upvotes: 4