I believe you need to use the key wrapText instead of wrap
'A' => ['alignment' => ['wrapText' => true]],
Documentation: https://phpspreadsheet.readthedocs.io/en/latest/topics/recipes/#styling-cell-borders
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have an Export class function, with several sample style treatments (bold, italic, size):
class TransactionsExport implements FromCollection, WithHeadings, WithMapping, WithStyles
{
public function styles(Worksheet $sheet)
{
return [
// Style the first row as bold text.
1 => ['font' => ['bold' => true]],
// Styling a specific cell by coordinate.
'B2' => ['font' => ['italic' => true]],
// Styling an entire column.
'C' => ['font' => ['size' => 16]],
];
}
It works. I see that output on a spreadsheet that is generated by Laravel Excel.
But the PhpSpreadsheet on which Laravel Excel appears to be wrapped also provides for an alignment treatment--but written in PHP, according to its documentation:
$spreadsheet->getActiveSheet()->getStyle('A1:D4')->getAlignment()->setWrapText(true);
I've tried a million ways to guess how Laravel Excel might implement that, if it even does. I've tried variations on
'A' => ['alignment' => ['wrap' => true]],
All to no avail.
If I know that PhpSpreadsheet does probably provide for a text wrap, then how can a statement that is constructed like
$spreadsheet->getActiveSheet()->getStyle('A1:D4')->getAlignment()->setWrapText(true);
be stitched into that function reproduced above?
I believe you need to use the key wrapText instead of wrap
'A' => ['alignment' => ['wrapText' => true]],
Documentation: https://phpspreadsheet.readthedocs.io/en/latest/topics/recipes/#styling-cell-borders
Please or to participate in this conversation.