vb.net - line break in CSV -
what character or combination of characters have insert csv file if enable line breaks in excel text correctly breaked @ point?
private sub removehtmltags(byref text string) dim htmltagregex new regex("<[^>]*>") dim linebreakhtmltagregex new regex("(<p>)|(<br>)|(</br>)|(</p>)") text = linebreakhtmltagregex.replace(text, chr(10)) text = htmltagregex.replace(text, " ") text = text.trim end sub
instead of chr(10) tried vbnewline, vbcrlf, vbcr every time same result: when file opened excel signs interpreted normal line breaks, leads split of rows in excel
that's should like:
this like:
how need achieve style in second screenshot if want load csv file double-clickling it, not on import dialogue
remark: not vba, need on external vb.net console application opens excel after csv file created.
if want include cr
, lf
control characters need wrap field in double quotes.
if suggest should put double quotes round every field consistency.
so method this:
private sub removehtmltags(byref text string) dim htmltagregex new regex("<[^>]*>") dim linebreakhtmltagregex new regex("(<p>)|(<br>)|(</br>)|(</p>)") text = linebreakhtmltagregex.replace(text, chr(10)) text = htmltagregex.replace(text, " ") text = "" & text.trim & "" end sub
more details can found here: http://www.creativyst.com/doc/articles/csv/csv01.htm
Comments
Post a Comment