Using fromArray, setWrapText, setAutoFilter cannot get \n multi new line in cell to display correctly in Excel5

Topics: Developer Forum, User Forum
Apr 10, 2014 at 6:58 AM
Edited Apr 10, 2014 at 9:52 AM
Add info - Using PHPExcel 1.8.0 with PHP 5.3.4 and OS: Win 7

I have the following code
    $objPHPExcel->getActiveSheet()->fromArray($DATAARRAY, NULL, 'A1', true);
    $HighestCol = $objPHPExcel->getActiveSheet()->getHighestDataColumn();
    $HighestRow = $objPHPExcel->getActiveSheet()->getHighestDataRow();

    foreach($objPHPExcel->getActiveSheet()->getRowDimensions() as $rd) {


    foreach(range('A',$HighestCol) as $columnID) {
    header('Content-Type: application/');
    header('Content-Disposition: attachment;filename="myfile.xls"');
    header('Cache-Control: max-age=0');

    $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
From the above code, my $DATAARRAY contain some that have new line in some of the cell.

When open the Excel file, those cell that is suppose to have new line, require me to double click on the cell, in order to reflect the correct height.

May I know which part of my part I did wrong.

Thank you.
Apr 15, 2014 at 2:28 AM
Edited Apr 15, 2014 at 2:29 AM
Hi everyone,

Below is the solution that I manage to find out. (just in case anyone need it)

Just change the line
to this