SSRS:根据参数值有条件地隐藏列 - CSV 导出忽略

问题描述:

我在 SSRS 2008 中有一个简单的基于表格的报告,有 10 列,每列都有一个相应的参数来确定是否应显示该列.我通过设置在设计模式下右键单击列标题时获得的列可见性选项来实现这一点.在我的例子中,我选择基于表达式显示或隐藏",我将表达式设置为布尔类型参数的值.

I have a simple table based report in SSRS 2008, There are 10 columns and each column has a corresponding parameter to determine whether the column should be shown. I achieve this by setting the Column Visibility option you get when right clicking on the column header in design mode. In my case I choose to 'Show or Hide based on an expression' to which I set the expression to the value of a parameter which is a boolean type.

该功能在初始渲染期间按预期工作,但是当我选择将报告导出为 CSV 时,可见性表达式要么被忽略,要么不被评估,因为无论设置如何,列都会显示.

The functionality works as expected during the initial render however when I choose to export the report to CSV the visibility expression is either ignored or not evaluated because the columns show up regardless of the setting.

可见性对话框有三个选项,基于表达式显示/隐藏/显示或隐藏 - 如果我明确设置隐藏选项,CSV 导出不会像您期望的那样包含该列,但是如果我使用表达式,它会 - 我什至甚至使表达式像 '=True' 一样显式,但它仍然被忽略.

The visibility dialog has three options, Show/Hide/Show Or Hide based on expression - If I explicitly set Hide option the CSV export does not include the column as you would expect however if I use an expression it will - I even went so far as to make the expression explicit like '=True' and still it was ignored.

如何获得导出选项以正确评估?

How do I get the export option to evaluate this properly?

您不能使用表达式隐藏或省略导出的列.这是因为表达式只会在报告本身中进行评估,而不会在导出中进行评估.

You cannot hide or omit columns for the export, using expressions. This is because the expressions will only get evaluated in the report itself, not the export.

一种解决方法是默认隐藏列并使用表达式显示所有其他列.

抱歉,上面的说法毫无意义.似乎您需要做的是创建一个参数来显示要隐藏或显示哪些列,然后在报表运行时不要在这些列中显示任何数据.您还可以根据这些参数更改列标题的值.

my apologies, that above statement made no sense. It seems what you will have to do is make a parameter that will show which columns to hide or display, then when the report runs just don't display any data in those columns. You can also change the value of the column heading based on these parameters.

唯一的另一种选择是使用不同的列组合创建尽可能多的报告,然后动态加载正确的报告.

The only other option is to create as many reports with the different column combinations then load the correct one dynamically.