在 SSRS 中,是否可以从报告函数中引用报告变量?
下面是我的报告功能。与其在函数中声明和设置 MaxRFWIDRange,不如引用同名的报告变量。
Function ValidateRFWIDRange(FromRFW As Integer, ToRFW As Integer) As Boolean
Dim DiffRFW As Integer
Dim MaxRFWIDRange As Integer
MaxRFWIDRange = 10000
DiffRFW = ToRFW - FromRFW
If DiffRFW > MaxRFWIDRange Then
Return False
Else
Return True
End if
End Function
最佳答案
看起来你可以做到这一点。
我通过添加一个变量 TestVariable
对此进行了测试。到报告,然后添加以下自定义代码:
Function TestVariableFunctionality(var as Microsoft.ReportingServices.ReportProcessing.OnDemandReportObjectModel.Variable) As String
Return var.Value
End Function
我从文本框中调用该函数,如下所示:
=Code.TestVariableFunctionality(Variables!TestVariable)
这会将文本框中的变量值作为字符串输出。
您必须将完整的命名空间声明为
Microsoft.ReportingServices.ReportProcessing.OnDemandReportObjectModel.Variable
, 因为 Variable
单独没有定义。请参阅下文了解更多信息。Accessing variable in SSRS function
From an MSDN blog:
Assume that you've created a report variable named "Reportvariable1".
All you need is a piece of custom code.
Public Function SetVariableValue(val as Microsoft.ReportingServices.ReportProcessing.OnDemandReportObjectModel.Variable)
val.Value = val.Value + 2
End Function
As simple as that. All i'm doing in the function is, take the report variable reference, add 2 to the existing value. That's it.
How you can call this function from your report item?
=Code.SetVariableValue(Variables!Reportvariable1)
This will do the magic. Also note that in the above expression i'm just passing the variable reference and not its value.
关于function - 来自报告函数的 SSRS 引用报告变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40644956/