Closed DPineault closed 5 years ago
Try using a <BR>
tag for line break.
It is one of the things I tried and it did not work.
It truly seems to be an issue with needing to be able to enable Text Wrapping on a column, Can this be done?
You need to check the PHPSpreadsheet documentation to control cell formats.
I know who to do it
->getAlignment()->setWrapText(true);
that's not the issue, but have no clue how to integrate it into the export widget, column setting, ...?
Configure the above within the onRenderCell property of the widget as Closure
Sorry to bother you, but I just can't get it to work. Any chance you could provide a simple sample or point out what I'm doing wrong.
I've tried
'onRenderDataCell' => function ($cell) {
$cell->getAlignment()->setWrapText(true);
},
(The above generates a 'Call to undefined method PhpOffice\PhpSpreadsheet\Cell\Cell::getAlignment()' error) Normally, I'd do something like
$sheet->getStyle('A'.$i)->getAlignment()->setWrapText(true);
(where $i is the row number) just not sure how to do the same in the widget onRenderDataCell
With further testing, I managed to get the following to work, but is there a way to dynamically define the last data row?
'onRenderSheet' => function($sheet){
$sheet->getStyle('Q2:T1000')->getAlignment()->setWrapText(true);
},
basically replace the hardcoded 1000 with however many rows are being exported?
and Thank you so very much for taking the time to help me. It is greatly appreciated!!!
Line breaks work on my exports no problem. Can you open in a plain text editor and see if the breaks are there? This seems like an excel config or version issue more than anything.
On Mar 27, 2019, at 7:57 PM, DPineault notifications@github.com wrote:
Sorry to bother you, but I just can't get it to work. Any chance you could provide a simple sample or point out what I'm doing wrong.
I've tried
'onRenderDataCell' => function ($cell) { $cell->getAlignment()->setWrapText(true); },
(The above generates a 'Call to undefined method PhpOffice\PhpSpreadsheet\Cell\Cell::getAlignment()' error) Normally, I'd do something like
$sheet->getStyle('A'.$i)->getAlignment()->setWrapText(true);
(where $i is the row number) just not sure how to do the same in the widget onRenderDataCell
With further testing, I managed to get the following to work, but is there a way to dynamically define the last data row?
'onRenderSheet' => function($sheet){ $sheet->getStyle('Q2:T1000')->getAlignment()->setWrapText(true); },
basically replace the hardcoded 1000 with however many rows are being exported?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Line breaks work on my exports no problem. Can you open in a plain text editor and see if the breaks are there? This seems like an excel config or version issue more than anything.
@ThreepE0 how do you make it work?
@DPineault @temirfe
This is how you do it in the settings:
'onRenderSheet'=>function($sheet, $grid){
$sheet->getStyle('A2:'.$sheet->getHighestColumn().$sheet->getHighestRow())
->getAlignment()->setWrapText(true);
}
Export not respecting line breaks
In my view I have
As you can see, I've tried a variety of line break approaches, but the end result is everything displaying on one line.
In Excel, the odd thing is that if I select the cell and click in the formula bar, then exit (having actually changed nothing at all), then the items display on their own individual lines?! It seems to be an issue with the 'Wrap Text'.
Is there a way to display content on multiple lines properly? Is there a way to apply ...->getAlignment()->setWrapText(true); to an export column?