Inserting multiline text in a csv field

倾然丶 夕夏残阳落幕 提交于 2019-12-08 15:04:43

问题


I want to insert a multiline text data in a CSV field.

Ex:

var data = "\nanything\nin\nthis\nfield";
var fields = "\"Datafield1\",\"Datafield2:"+data+"\"\n";

When I save fields into a csv file and open it using MS Excel, I get to see only the first column. But when I open the file using a text editor I see:

"Datafield1","Datafield2:
anything
in
this
field"

I don't know whether I am going against CSV standards. Even if I am going against Please help me with a workaround.

Thanks...


回答1:


By default MS Excel uses semicolon as a separator. use ; and you'll see this:




回答2:


Here I place some text followed by the NewLine char followed by some more text and the whole string MUST be quoted into a field in a csv file.

Do not use a CR since EXCEL will place it in the next cell.

""2" + NL + "DATE""

When you invoke EXCEL, you will see this. You may have to auto size the height to see the entire cell.

2

DATE

Here's the code in Basic

CHR$(34,"2", 10,"DATE", 34)


来源:https://stackoverflow.com/questions/10546933/inserting-multiline-text-in-a-csv-field

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!