【问题标题】:RDL 2016 Report Builder skip a line for an optional parameterRDL 2016 报表生成器为可选参数跳过一行
【发布时间】:2020-07-08 10:30:04
【问题描述】:
我有一个包含多个参数的 RDL 模板。它们都是可选的并被标记:
重要的是它们是可选的,因为有时地址不包含 AddressLine3(或者实际上是 AddressLine1 或 AddressLine2,甚至是 PostCode):
它们都放在一个文本框区域中,一切正常,但问题是如果我不传递可选参数之一(下例中的 AddressLIne2) - 报告中会保留一个空行:
关于如何使空行消失的任何想法?
【问题讨论】:
标签:
templates
reporting-services
ssrs-2012
rdl
【解决方案1】:
最简单的方法是用一个表达式替换 5 个参数的列表。像这样的。
=
Parameters!FullName.Value & IIF(IsNothing(Parameters!FullName.Value), Nothing, vbcrlf) &
Parameters!AddressLine1.Value & IIF(IsNothing(Parameters!AddressLine1.Value), Nothing, vbcrlf) &
Parameters!AddressLine2.Value & IIF(IsNothing(Parameters!AddressLine2.Value), Nothing, vbcrlf) &
Parameters!AddressLine3.Value & IIF(IsNothing(Parameters!AddressLine3.Value), Nothing, vbcrlf) &
Parameters!PostCode.Value
这只是将每个参数值与仅在参数不为空时添加的新行连接起来。
演示数据
以下显示了应用于示例 AdventureWorks 数据库中的某些地址数据的相同原理
报告显示所有地址字段以供说明
给出以下输出