简体   繁体   English

SSRS表达式中的新行

[英]New line in ssrs expression

I have an expression that suppose to be in one line. 我有一个表达式,假设是一行。 But the the number is jumping into another line in the textbox. 但数字跳到了文本框中的另一行。 What can I do to make it in one line. 我该怎么做才能使它成为一行。 The output is giving 输出给

2018-06-26HP-HPP
4

Code : 代码:

=Trim(Format(CDate(Fields!Startdate.Value), "yyyy-MM-dd")) & Trim(Fields!Register.Value) & Trim(DatePart(DateInterval.Hour,  Fields!GSTIME.Value)).ToString()

Expected answer should be : 预期答案应为:

2018-06-26HP-HPP4

Thanks 谢谢

Michael 迈克尔

If this is your expected result 如果这是您的预期结果

2018-06-26HP-HPP4

from

=Trim(Format(CDate(Fields!Startdate.Value), "yyyy-MM-dd")) & Trim(Fields!Register.Value) & Trim(DatePart(DateInterval.Hour,  Fields!GSTIME.Value)).ToString()

but you're getting this 但是你得到这个

2018-06-26HP-HPP
4

And the text box is large enough to show this on one line then I suspect you have a new line character in the field Fields!Register.Value 并且文本框足够大,可以在一行上显示它,那么我怀疑您在Fields!Register.Value有换行符

because 因为

the first part of the expected result ( 2018-06-26 ) comes from 预期结果的第一部分( 2018-06-26 )来自

Trim(Format(CDate(Fields!Startdate.Value), "yyyy-MM-dd"))

The second part ( HP-HPP ) comes from this 第二部分( HP-HPP )来自于此

Trim(Fields!Register.Value)

The final part (4) comes from this 最后一部分(4)来自此

Trim(DatePart(DateInterval.Hour, Fields!GSTIME.Value)).ToString()

The new line you're seeing in the text box is between the 2nd and 3rd parts which I suspect may be in the contents of Trim(Fields!Register.Value) 您在文本框中看到的新行位于第二部分和第三部分之间,我怀疑可能在Trim(Fields!Register.Value)的内容中

If this field is in a db table then when you select the column search and replace for hidden carriage returns, line feeds and tabs. 如果此字段在数据库表中,则当您选择列搜索并替换为隐藏的回车符,换行符和制表符时。

Here's one way 这是一种方法

DECLARE @tmp TABLE (tmp NVARCHAR(50))
INSERT INTO @tmp (tmp)
SELECT 'Help' + CHAR(10) + 'me' + CHAR(9) + 'please' + CHAR(13)

DECLARE @val NVARCHAR(50) = (SELECT tmp FROM @tmp )
PRINT @val

output 产量

Help
me  please

remove the hidden characters 删除隐藏的字符

SET @val = (SELECT REPLACE(REPLACE(REPLACE(ISNULL(tmp,' '), CHAR(10), ' '), CHAR(13), ' '), CHAR(9), ' ') FROM @tmp )
PRINT @val

output 产量

Help me please

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

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