how to replace \n with alt+enter while exporting to .CSV
-
how to replace \n with alt+enter while exporting to .CSV HI, I am writing line by line to a file(.CSV). If the string is having "\n" in between then the multiline is not possible for a single cell and it is coming to the next line of Excel . Can anyone help me to replace the "\n" with "Alt+Enter" equivalent? I am using CSting to collect the entire line at a tiime. I am trying as below CSting temp; temp.Replace("\n", "")); Thanks SMA
-
how to replace \n with alt+enter while exporting to .CSV HI, I am writing line by line to a file(.CSV). If the string is having "\n" in between then the multiline is not possible for a single cell and it is coming to the next line of Excel . Can anyone help me to replace the "\n" with "Alt+Enter" equivalent? I am using CSting to collect the entire line at a tiime. I am trying as below CSting temp; temp.Replace("\n", "")); Thanks SMA
Let the line feed in place and enclose the cell content by double quotes. This should be accepted by Excel when rows are terminated by carriage return - line feed pairs. So your CSV file should look like:
Row1:Col1, "Row1:Col2\n with new line"\r\n
Row2:Col1, "Row2:Col2, with comma"\r\n
Row3:Col1, "Row3:Col2 with "" esacped quote"\r\n
Row4:Col1, " Row4:Col2 begins and/or ends with space "\r\nAs an alternative you may write HTML files using tables. These can be also imported by Excel.