SSRS 在文本框表达式中重复文本

SSRS repeating text within a textbox expression

是否可以编写一个表达式,将某些文本一遍又一遍地重复指定的重复次数,或者直到用完文本框中的 space 为止?

需要显示的文本来自共享数据集中的一个字段,并且可以根据用户连接到的数据库而改变。

我需要循环的是

="~~"&First(Fields!SchemaText.Value,"Selection") &"~~"

如果可能的话,我想要的输出是

~~Text~~~~Text~~~~Text~~~~Text~~~~Text~~

基本上可以在 SSRS 中循环表达式吗?

我不确定你能不能直接把它写成一个表达式..

如果我是你,我会尝试编写一个新的 1 列数据集,其中包含你想要包含文本值的行数。然后,在文本框表达式中,我将尝试使用 join().

获得结果

我没有测试,抱歉,我可能错了。

我没有找到在表达式中写入的方法。

我认为最简单的方法是在 VB 中创建一个函数。

Function RepeatText(ByVal Text As String, ByVal Loops AS Integer) As String 

Dim F AS Integer

RepeatText = ""

For F = 1 to Loops 

    RepeatText = RepeatText & "~~" & Text  & "~~"

Next F

End Function

您的文本框表达式类似于:

=CODE.RepeatText(Fields!SchemaText.Value, 4) 

您需要用一些代码替换 4 以确定文本重复的次数,或者您可以更改代码以计算出重复次数基于另一个领域。

=CODE.RepeatText(Fields!SchemaText.Value, Fields!SOME_OTHER_FIELD.Value)

然后让代码弄清楚:

Function RepeatText(ByVal Text As String, ByVal Type AS String) As String 

Dim F AS Integer
Dim END AS Integer

If Type = "DB1" then END = 1 
If Type = "DB2" then END = 2 
If Type = "DB3" then END = 3 

RepeatText = ""

For F = 1 to END

    RepeatText = RepeatText & "~~" & Text  & "~~"

Next F

End Function

SSRS 有一个名为 StrDup 的文本函数。 不知道什么时候有这个功能,也不知道这个功能是不是一直都有。

语法:StrDup(整数, (char | object | string))

EX: =StrDup(3,"结束...") 输出:结束...结束...结束...

EX: =StrDup(3, Chr(149)) & "文本" 输出:•••文本

看这里: https://www.mssqltips.com/sqlservertip/4093/sql-server-reporting-services-string-manipulation/

或者在互联网上搜索“SSRS StrDup”