开发者

SSRS: Conditionally hiding columns based on parameter values - CSV export ignores

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.

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.

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?


Here's a solution by KarenH in the article Hide/Show Items Dependant On Export Format

Basically, you can set the DataElementOutput = NoOutput on the control you want to hide.

This worked for me to hide tables when exporting to CSV.

SSRS: Conditionally hiding columns based on parameter values - CSV export ignores


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.

a workaround would be to hide the columns by default and show all others using the expression.

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.


I believe this may be a bug. I have used the Reporting Services export with hidden columns dependant on a parameter at runtime. If I run the report with the columns hidden and then export the result to Excel or PDF or most exports formats the hidden columns are NOT exported. If I export the report to a CSV file, the hidden columns ARE exported. Surely this is a bug in the CSV export.

Logically they should all behave in the same way.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜