Newlines in Data Create Strange Repeating Values

Topics: User Forum
Oct 13, 2012 at 4:01 AM

I've got some data from form entries with newline characters.  Say something like "hello\nbye". If I put the value in cells like this:

$sheet->setCellValueByColumnAndRow($col, $row, $val);

I get a seemingly random repeating set of that value in the cell like:

hello
bye
hello
bye
hello
bye 

But if I do something like this to get ride of the newlines:

$sheet->setCellValueByColumnAndRow($col, $row, preg_replace("/[\r\n\f]+/", '', $val));

I just get the value once.

I'm using the Excel2007 version.  Anybody have any ideas why this would be, or seen anything similar?  I can replicate consistently with my data, happens every time.  I've tried everything I can think of, but if there's a newline character in there, this oddity happens.