Why do multiline cells in my CSV file appear with a question mark at the end of each line in Excel?

点点圈 提交于 2019-12-10 11:25:45

问题


I'm currently working on a project where we'd like to allow a user to export their data to CSV. Some of the data we present has multiple values for a single cell, and so we use the standard CSV method of putting each value on its own line:

Column A, Column B, Column C
Value A, "Value B1
Value B2", Value C

Most of the time this works fine, but some people are reporting seeing a small question mark in a box character appear at the end of each line when they load the file in Excel. Why is this happening?


回答1:


Although the RFC for CSV(http://www.rfc-editor.org/rfc/rfc4180.txt) seems to imply that line breaks should be written as \r\n (CRLF), this is not the format that Excel outputs, and attempting to load files with this format seems to sometimes cause a problem where the [CR] character is displayed as if it were an unknown character.

The CSV format that Excel uses has newlines within a cell represented with a single LF character, and newlines between rows represented using CRLF. So the example above should be formatted:

Column A, Column B, Column C[CR][LF]Value A, "Value B1[LF]Value B2", Value C[CR][LF]



来源:https://stackoverflow.com/questions/2436572/why-do-multiline-cells-in-my-csv-file-appear-with-a-question-mark-at-the-end-of

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