Column Visibility when Exporting to CSV - reporting-services

Can someone tell me why this doesn't work?
I have the "Column Visibility" set to "Show or hide based on an expression"
The expression is the following:
=IIF(Globals!RenderFormat.Name = "CSV",True,False)
Save to CSV, Column shows.

Format options such as expressions on visibility are ignored for CSV rendering methods. CSV rendering methods are essentially data flows, so you can suppress elements that you don't want to include in CSV files by changing the DataElementOutput from Auto, the default value, to NoOutput.

Related

Hide fields in SSRS report based on expression

i have one problem with exporting to CSV format. In my report i user parameter to hide on field and it's working ok except for exporting in CSV format.
Column visibility is see like this:
=IIF(Parameters!ShowBonusLockingData.Value="False",true,false)
but this doesn't work in CSV. Can someone help me with this problem. Setting column property to NoOutput is not a solution, because that property never shows the column then

Hide field when export to CSV in SSRS with expression

I want to hide one field in SSRS when I export the report. I know that if I put NoOutput property it will work but I have one more expression that I want to put for field visibility. I have this expression for my visibility and works fine for Excel, PDF,...
=IIf(Parameters!Limited.Value=false,false,true)
But when I export to CSV this doesn't work.
How can I improve this so that it also works for CSV?
You have to remember that there are 2 types of exports in SSRS:
Data export - CSV and XML
Image based export - Word, PDF, Excel, TIFF, printing
The visibility property will only be read when you export to an image based export, and the data output property will only be read when using a data export.
If you can live with having the column there with the data being blank, then use Aldrin's method. If you want the column to not be there when exported and the columns you don't want to export is known in advanced, you're can use d b's way which is have 2 different tables, 1 for display but all the data is no output, the other output only for data export and visibility hidden.
If you need to do "No Output" dynamically, then that is pretty much impossible as a limitation of SSRS.
Put this script under Visibility property.
=IIF(Globals!RenderFormat.Name = "CSV", True, False)
or Just this
=Globals!RenderFormat.Name = "CSV"
It is not possible to conditionally hide a field for CSV output in SSRS.
But if it is very important to you, you can go through the trouble of creating 2 (or more) nearly-identical tables and show/hide the entire tables conditionally.
The contents of hidden tables (as opposed to rows and cells) do not get exported to CSV.
=IIF(Globals!RenderFormat.Name = "CSV", True, False)
This doesn't work.
The only option is to create as many reports with the different column combinations then load the correct one dynamically.

SSRS 2008 Stop Tablix from Exporting to CSV

I have two Tablix controls on my SSRS report. I want one of them to export and one not to export. I have accomplished this by setting the hidden property on the one I want to export to:
"=Globals!RenderFormat.IsInteractive = True"
and the one I do not want to export to:
"=Globals!RenderFormat.IsInteractive = False"
This works perfectly when I export to Excel, however CSV simply ignores these values and exports both Tablix controls. I need to know how I can force CSV to only export one Tablix control.
Format options such as expressions on visibility are ignored for CSV rendering methods. CSV rendering methods are essentially data flows, so you can suppress elements that you don't want to include in CSV files by changing the DataElementOutput from Auto, the default value, to NoOutput.
You can't conditionally set the DataElementOutput, but you can conditionally set the tablix filters. That will leave the header row in the csv output, but trims the data rows.
Try setting the visibility.hidden property of the tablix you don't want to export to CSV to:
=(Globals!RenderFormat.Name = "CSV")
http://blogs.msdn.com/b/robertbruckner/archive/2010/05/02/globals-renderformat-aka-renderer-dependent-report-layout.aspx

SSRS csv export with comma in the column header names

By default, csv takes the text box name as the csv header name for the columns. The text box does not allow a space.
How do I make a different header than the text box for the csv?
Is there a way to display comma in the header when exported to csv?
Note: The solution has to be only for one report; not global.
The column name comes from the DataElementName property, or if that is blank, the Name property. Unfortunatly, neither allow commas or quoting.
There is a blog post here:
http://www.behindthecode.net/Blog/post/2008/01/29/How-to-modify-Reporting-Services-CSV-export-Behavior.aspx
on how to change settings in the config file for csv exports. These are global changes. The list of properties available is here:
http://msdn.microsoft.com/en-us/library/ms155365.aspx
None of these allow the spaces you need, or the quoting of column names that I am currently trying to achieve. Sorry.
In short, No, it's not possible.
From SSRS 2008 Column issue when exporting to a CSV file:
For csv export, the header of a column is determined by the DataElementName property of the textbox which actually contains the data. If the DataElementName property is not explicitly set by the user, DataElementName automatically gets defaulted to the value of the textbox.Name property.
That being said, I believe you're getting this issue because RDL has a restriction that both a reportItem.Name and reportItem.DataElementName property must be CLS-compliant identifiers. The headings like "Phone #", "Other Name(s)", etc... are not CLS-Compliant.
You can verify this by opening up the report in BIDS or RB and trying to set the DataElementName/Name property of the textbox containing the data to those names.
You will get an error which states the following:
Property Value is not valid. Specify a valid name. The name cannot contain spaces, and it must begin with a letter followed by letters, numbers, or the underscore character (_).
There is a Microsoft Connect Issue about this, but unfortunately it looks like it won't be acted on.
See: Use of expressions for DataElementName property (for CSV Export)
This solution works: https://stackoverflow.com/a/32110072/674237
In summary:
Modify your query to have the first row in the data set be your desired column headers. E.g., select header names and union them to the data set.
Add a new CSV rendering extension to the report server that excludes headers.
This workaround will let you to put whatever values you'd like in the headers.
Append the following query parameters to your url:
For # - [url]&rs:format=CSV&rc:FieldDelimiter=%23
For ; - [url]&rs:format=CSV&rc:FieldDelimiter=";"
Not sure you can do it directly from Report Manager without altering config files somewhere
Update: After rereading this, are you returning the column headers from the procedure like this?
SELECT tbl.colname [my column name, some text],
tbl.col2 [another, col]
The square brackets will allow you to escape characters.
Column names for Csv, Dbf and Xml are picked up from <Name> field by default.
Solved this issue by adding appropriate names for each of this formats in <Tag> field in *.mrt file. E.g:
<Name>Txt_InternalName</Name>
<Tag>CSV:"Name for Csv"; DBF: "Name for DBF"; XML: "Name for Xml"; Default: "Default Name for Csv Dbf Xml"</Tag>
Also it resolves issue with CLS non compliant identifiers in headers

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.
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.