I am using this code with PHPExcel to break a text into multiple lines in a cell (if needed).
$excelSheetRowNumber = 1;
$col = 'A';
$objPHPExcel->getActiveSheet()->setCellValue($col . $excelSheetRowNumber, $task->getName());
$objPHPExcel->getActiveSheet()->getStyle($col . $excelSheetRowNumber)->getAlignment()->setWrapText(true);
The only problem is that if the text is wrapped, the last line is shown by default. I would like to have the first line to be shown.
To give you an example of what I mean, if I have this long text:
first line first line first line first line second line second line second line
And it gets broken up by PHPExcel like this:
first line first line first line first line
second line second line second line
what I see in the cell when I open the spreadsheet is:
second line second line second line
as opposed to:
first line first line first line first line
Normally, setting a cell to autowrap will also set the row to autofit. I’m unable to replicate your problem: what writer are you using?
However, you might try: