简体   繁体   English

使用SQL查询导出到Excel时应用换行符

[英]Apply line breaks when export to Excel using SQL query

I have the below select query. 我有以下选择查询。 I have used this data to export to Excel using C# code. 我已使用此数据通过C#代码导出到Excel。 The export is working and I applied CHAR(13) for line breaks. 导出正常,我将CHAR(13)应用于换行符。 But after the export, the data is showing up without line breaks. 但是,导出后,数据显示没有换行符。 But when I click the cell it is applying the line break. 但是,当我单击单元格时,它正在应用换行符。 How do apply line breaks in export? 如何在出口中应用换行符?

My query: 我的查询:

REPLACE(somestring, '<br/>', CHAR(13))

Try using Char(10) 尝试使用Char(10)

REPLACE(somestring,'<br/>', CHAR(10))

Carriage return (Char(13)) might not show up how you expect in the editor you're using. 回车符(Char(13))可能不会在您使用的编辑器中显示您的期望。

If that doesn't work try 如果那不起作用,请尝试

REPLACE(somestring,'<br/>', char(13)||char(10))

New lines can be annoying. 新行可能很烦人。

Also make sure you have wrap text selected in Excel. 另外,请确保已在Excel中选择了自动换行文本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM