setRowHeight(-1) doesn't work

Topics: Developer Forum, User Forum
Jan 26, 2011 at 6:02 AM
Edited Jan 26, 2011 at 6:07 AM

Hi,

$objPHPExcel = new PHPExcel();
$objReader = PHPExcel_IOFactory::createReader('Excel5');
$objPHPExcel = $objReader->load("xls/report_template.xls");
$val="line1\r\nline2"
$objPHPExcel->getActiveSheet()->setCellValue(A1, $val);
$objPHPExcel->getActiveSheet()->getRowDimension(1)->setRowHeight(-1);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save("../../files/_tmp/fichier.xlsx");

 

I see "line1|line2" in Microsoft Office 2007, I have to resize manually the row but works well on LibreOffice 3.3.0 where I can see:

line1
line2

How can I resolve this problem on Microsoft Office 2007?

How can I simulate ALT+ENTER ?

Thanks for your help.

Coordinator
Jan 26, 2011 at 8:15 AM

It's cleaner if you just use \n rather than \r\n

But you also need to set text alignment to wrap

$objPHPExcel->getActiveSheet()->getStyle('A1')->getAlignment()->setWrapText(true);