Importing CSV with line breaks in Excel 2007

Posted by ph0enix on Stack Overflow See other posts from Stack Overflow or by ph0enix
Published on 2010-04-19T15:31:14Z Indexed on 2010/04/19 15:33 UTC
Read the original article Hit count: 156

Filed under:
|

I'm working on a feature to export search results to a CSV file to be opened in Excel. One of the fields is a free-text field, which may contain line breaks, commas, quotations, etc. In order to counteract this, I have wrapped the field in double quotes (").

However, when I import the data into Excel 2007, set the appropriate delimiter, and set the text qualifier to double quote, the line breaks are still creating new records at the line breaks, where I would expect to see the entire text field in a single cell.

I've also tried replacing CR/LF (\r\n) with just CR (\r), and again with just LF (\n), but no luck.

Has anyone else encountered this behavior, and if so, how did you fix it?

TIA,
-J

© Stack Overflow or respective owner

Related posts about excel-2007

Related posts about csv