将 CR+LF 复制并粘贴到 Excel 电子表格中时出现问题,需要软段落 (Alt+Enter)
我正在尝试将我们软件中创建的表格复制到 Excel 电子表格中。
我们应用程序中的一些标题标题太大,无法放入一列中,因此它们由 #13+#10 (CR+LF) 分隔,因此它们位于下一行。例如,
Strain SpikeConc Spike
ng/g dpm/g
-------------------------
Blah 20.0 50.1
Blah2 22.1 60.2
但是,当将其复制到 Excel 中时,我们会发生奇怪的事情。 CR+LF 被解释为(你猜对了)新行请求。因此我们得到的东西看起来完全错误。例如,
Strain SpikeConc
ng/g Spike
dmp/g
-------------------------
Blah 20.0 50.1
Blah 22.1 60.2
它错误地解释了 SpikeConc 后的 CR+LF 并在新单元格中创建新行,而不是像按 Alt+Enter 并在同一单元格中为您提供新行那样创建软段落。
有人知道如何编码软段落而不是新行吗?
我尝试过单独使用 CR (#13) 和 LF (#10),但它们都有相同的行为。
我相信有一些 unicode 字符
LS:行分隔符,U+2028
PS:段落分隔符,U+2029
但我似乎找不到如何将它们编码到我的应用程序中的表中。
PS我们使用的是Delphi6(不要问)
I'm trying to copy a table that is created in our software into an excel spreadsheet.
Some of the title headers in our application are too big to fit in a column so they are separated by a #13+#10 (CR+LF) so they sit on the next line. e.g.
Strain SpikeConc Spike
ng/g dpm/g
-------------------------
Blah 20.0 50.1
Blah2 22.1 60.2
However, when this is copied into excel we get a strange thing happening. The CR+LF is interpreted as (you guessed it) a new line request. Hence we get something that looks totally wrong. e.g.
Strain SpikeConc
ng/g Spike
dmp/g
-------------------------
Blah 20.0 50.1
Blah 22.1 60.2
It is interpreting the CR+LF after the SpikeConc incorrectly and creating a new line in a new cell instead of creating a soft paragraph like you would get if you pressed Alt+Enter and giving you a new line in the same cell.
Anyone got any ideas how to encode a soft paragraph rather than a new line?
I've tried using just CR (#13) on it's own and just LF (#10) on it's own but they both have the same behaviour.
I believe there are some unicode characters
LS: Line Separator, U+2028
PS: Paragraph Separator, U+2029
but I can't seem to find how to encode them into the table in my App.
PS We're using Delphi6 (don't ask)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
太棒了。如果我这样写,
它会在 Excel 中正确显示,
谢谢。这让我发疯。
That's Brilliant. If I put it like this
it displays it correctly in excel like this
Thanks. That was driving me crazy.
正如评论中提到的,这是我们用来剥离 CR 的函数。无论是使用此方法还是将字符串括在双引号中都足以在 Excel 中实现软返回。
As mentioned in the comments, this is the function we use to strip the CR's. Either this or enclosing the string in double quotes suffices to have a soft return in excel.