2
votes

I'm using SSRS 2012 trying to do the following:

Some columns should only be visible on user request, using a combo box. Visibility of the columns dependes on the selected columns on the combo. This seems to work fine!

When I export the output in any format different of .csv these columns remain invisible. But when exporting to .csv invisible coulmns are shown.

I found this:

=iif(Globals!RenderFormat.Name="CSV", True, False)

This should be placed in the "Hidden" property of the column I'm trying to hide. But it doesn't work and when I write the expression RenderFormat is not an option as auto-complete.

Sorry for my clumsy english and thanks.

2

2 Answers

4
votes

CSV (and XML) export from SSRS is treated very differently than most export formats. These two are considered data renderers, not page renderers, and are generally written to get at the data underlying the report, disregarding layout options. Part of this is that field visibility isn't handled the same way. I don't know if it's a bug or intentional design, but .CSV apparently doesn't honor visibility set in expressions. One suggested work around is to conditionally set the value to null in the underlying dataset. (This could be based on a parameter.)

1
votes

There is a native way to hide data elements sent to CSV by using DataElementOutput=NoOutput

  1. Open the properties menu (F4) for the TextBox

  2. Set the DataElementOutput property to NoOutput

    screenshot

Further Explanation

When SSRS has to render a chart, it has a couple of decisions to make. If you spent a lot of time doing some cool formatting, it will try to preserve that when going to PDF because PDF documents are full of rich formatting. For example, if you set the margins of the report, a PDF should care, but a CSV has no way to even hold that information (nor should it).

As such, there are different rendering engines used by SSRS:

Render Engines

Each of these has their own process. The data exports, for example, will only pull information from datafields. For example, a data field is welcome to have several layers of headers, the names of which may or may not use CLS-compliant identifiers, so it's safer to extract that information directly from the textbox name itself.

The TextBox containing the data can be used to set other data export properties as well.

In this instance, you can remove a particular data field by using the DataElementOutput which:

Indicates whether the data point should appear in a data rendering.

Further Reading