开发者

csv file enclosed with double quotes not stripping quotes

I am generating a csv download from my web server and to be safe, I have enclosed each field with double quotes.

i.e.

"Field1","Field2","Field3","Field4"
"row1_field1","row1_field2","row1_field3","row1_field4"
"row2_field1","row2_field2","row2_field3","row2_field4"

The problem is that when the file is opened in Excel, it does not strip all quotes... Therefore, some fields are appearing as: row1_field1 whereas others are a开发者_JS百科ppearing as "row1_field2"

What am I not doing to ensure that excel strips all surrounding quotes?


Make sure there are no spaces around the commas. So the following should work:

"row1_field1","row1_field2","row1_field3","row1_field4"
"row2_field1","row2_field2","row2_field3","row2_field4"

But this will show up with the quotes in place:

"row1_field1", "row1_field2", "row1_field3", "row1_field4"
"row2_field1", "row2_field2", "row2_field3", "row2_field4"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜