Reading a Multi line cell

Topics: Developer Forum, User Forum
Jan 31, 2012 at 10:06 PM

I have to process some spreadsheets (.xlsx & .xls) with the relevant Excel reader object however when accessing the data for a cell with multiple lines (entered using Alt-Enter or Cmd-Alt-Enter) the reader only returns the first line... so:-

Cell 5:55 is:-




$phpExcelWorksheet->getCellByColumnAndRow(5,55)->getValue() only returns 'AAAA' ...

Is there a setting/parameter I can pass to get AAAA\nBBBB\nCCCC or similar?



Feb 1, 2012 at 7:46 PM

Are you sure that's all it's returning? All readers should return the full content of a cell, irrespective of how many lines it is.

Jul 10, 2012 at 12:28 PM

Same problem here but only with (.ods) file. Gnumeric, xls and xslx works great.

Jul 10, 2012 at 9:47 PM

Could you please try this with the latest github code: this problem should already have been fixed

Jul 12, 2012 at 10:57 AM

Thanks Mark,
   the latest version takes all the cell's content but I'm not able to show the multi-line with the nl2br() php function as I do with xls, xlsx and gnumeric.

I will try other methods now.


Jul 12, 2012 at 11:09 AM


well, this do not work with ods file:

print(preg_replace( "/(\r\n|\r|\n)/", "<br />", ($mySheet[3][2]))); 

It looks like there are not carriage return in the cell's content.


Thanks in advance,


Jul 12, 2012 at 4:45 PM

It should be a simple \n that's set as a line break character

Will double check

Jul 13, 2012 at 7:38 PM

str_replace("\n", " ", $objWorksheet->getCellByColumnAndRow($col, $row)->getValue())
I used that because there were some cells in the sheet I was reading in that had newlines in them and it worked fine to remove them.