ssrs 2008 r2 export to csv displays column all the time - reporting-services

In an SSRS 2008 R2 report, the users are going to export the data to: csv (comma delimited) and excel.
I am using the following to display if a column is visible or not:
=IIF(Mid(Globals!RenderFormat.Name,1,5)="EXCEL" AND First(Len(Fields!CustomerNumber.Value)) > 0,False,true)
I have set the DataElementOutput=Output for the textbox that displays the value.
I have left DataElementOutput=Auto for the textbox that contains the column header.
When exporting to csv (comma delimited) or excel, I basically want the column to be visible when there is data in the field and the column not to be visible when there is no data.
The code works for excel but the code does not work for comma delimited.
Thus, can you tell me what I can do so the column is not disaplyed when the data is exported to csv (comma delimited)?

You may attempt to do this with a continuation of statement accounting for the "CSV" output type.
=IIF( (Mid(Globals!RenderFormat.Name,1,5)="EXCEL" OR Mid(Globals!RenderFormat.Name,1,5)="CSV") AND First(Len(Fields!CustomerNumber.Value)) > 0,False,true)
Or a switch statement:
=Switch(Mid(Globals!RenderFormat.Name,1,5)="EXCEL" AND First(Len(Fields!CustomerNumber.Value)) > 0,False, Mid(Globals!RenderFormat.Name,1,5)="CSV" AND First(Len(Fields!CustomerNumber.Value)) > 0,False,true)
However....
The problem may be due to the nature of a csv file being a simpler format that cannot handle this in output. It depends on how SSRS handles the output if it is hard writing the output before the write operation. It may simply not work because of the limitations of the format of CSV. If this was the case you may be able to simple take the Excel output and save it to CSV either in code or a manual operation.

Related

Access Query Export to Excel with formatting

My invoice number (Auto number) formatted like “Binu/21-22/”0000. While running the query, invoice number is showing “Binu/21-22/0001” which exactly I want When I am exporting it to excel with following VBA code -DoCmd.OutputTo acOutputQuery, "Qry_Test", acFormatXLSX, sFileName, True- that time also excel file is showing the format “Binu/21-22/0001” but when I am clicking on the invoice number on excel file cell then its showing only “1”. I want excel file also with the correct format “Binu/21-22/0001” instead of “1”. Anyone can help me how to resolve this”
I am assuming you are using format option to display invoice number as "Binu/21-22/"0000. So when it is exporting to excel then it is exporting with format not as value. So, you can write you query with FORMAT() function which will display as your desired format and export to excel will export as value. Try-
SELECT "Binu/21-22/" & FORMAT(MyTable.[InvoiceNo],0000) as [InvoiceNo] FROM MyTable
Save this query and then export to excel. Add your other fields in the query. as required.

Formatting of exported SSRS report to CSV file

My 2008R2 SSRS report contains a detail column called debit which is formatted like "#,0.00". When I export the file via .csv the debit column does not always have the right formatting of 0.00. If the number is 0, then what appears is "0". If the number is 123.40, then it appears as 123.4. If the number is 123.44, then it appears as 1213.44.
I want each number in this column to always have 2 decimal places in the .csv file. I checked out many other articles on stackoverflow about this, but none seem to address this issue correctly.
I tried changing the format to many other formats. I noticed when I changed the format in SSRS to "C" for currency, then the 2 decimal places appeared. But the problem with that is my users do not want the "$" symbol.
I tried changing the CSV export to ASCII format in the config file, but that did not work.
I used the code here:Non-Unicode CSV Export from SQL Server Report Server
Can anyone help me with getting the format correct in the CSV file without mannually changing the CSV file?
Thank you!
The problem mentioned is report header's are being displayed when user generate report for CSV format, which is not supposed to be like that. But actually in CSV Format, While in the preview , we can hide or show report header's and it doesn't show textbox names .
While in the exported/generated one , the CSV format hides the report's headers, but instead of that it shows textbox names and any changes We made in the properties to change that textbox name to make it as blank or disappear, it reflects on that column values but doesn't on that textbox name.
So I want to mention that better We can give some other meaningful names or by default it shows as 'Textbox1', but we must give any valid name to that textbox name and it appears on the generated CSV format.
NOTE: I also want to mention that all visibility properties works well with the report header's but not on the textbox names.

Numbers not keeping format when exported from SSRS 2008 R2 to Excel 2010

I am using an expression to display currency depending on if the value is in the millions or in the thousands. This expression is set in the Format property of my report:
=iif((Fields!PrevActual.Value < 100000), "'$'#,,0,'K';('$'#,0,'K')", "'$'0,,.0,'M';('$'0,,.0,'M')'")
In this way, if the value is 1,500,000 the number will display as $1.5M and if it's 15,000 it will display as $15k.
The problem is when I export the file to Excel. The numbers in the thousands retain the formatting, but the numbers in the millions lose it. So I have a spreadsheet with numbers like 1,500,000 and $15k. All numbers are exporting as text.
Does anyone know of a way to keep the formatting in excel so it matches how it's displayed on the SSRS report while making sure it's also still a number?
Essentially, I want to mimic what excel was doing before we automated this report with SSRS. Numbers in the millions were in this custom number format: $#.0,,\M and thousands were in this one: $#,K.
Thanks!
If you export the excel formula then it can work. i.e. export
="text(1500000," ""'$'0,,.0,'M';('$'0,,.0,'M')"")"
Excel will then convert the formula to the final formatted value
$15M
The tricky part is making the format string valid in excel, and creating an SSRS formula which will concatenate strings and generate an Excel formula.
This can help:
http://msdn.microsoft.com/en-us/library/ms159220%28SQL.90%29.aspx

ssrs csv export numeric values

I'm using SSRS to build a report that can be exported to multiple types (PDF, XLS, CSV...)
The report consists in a table and some columns have numeric values such as latitudes or longitudes, something like -1,234567
When exported to csv and opened in excel, these numeric values loose the ','
Is it possible to make this values as text in report builder so it's kept as it is, with no formating changes on the csv file?
tks
An easy way to do this is to use a Format expression instead of accessing your report field directly.
e.g.
=Format(Fields!OrderPrice.Value, "#,###.00")
instead of..
=Fields!OrderPrice.Value
This will coerce the numeric value into a string. The number format will ensure you keep the comma. When exported via CSV, the value will be wrapped in quotes, meaning your formatting comma won't trip a parser up.
Massive caveat
This solution is not perfect. The problem is that although you get the desired result in your CSV file, any SSRS Excel export you produce will flag that field as textual content, meaning that your users will have to tell Excel different every time they open that report.
Similarly, if someone opens your CSV file in Excel, the same thing will happen. Excel isn't smart enough to recognise that the thing in quotes is actually a number, and it'll again, treat the column as textual.
The reality is that CSV is a limited format. It's primary concern is content - it doesn't convey formatting information, and even if it were possible to give SSRS more "guidance" on individual export routines, the inherent limitations of the CSV file format mean that some sort of compromise ( or extra work on the Excel end ) has to be made.

The header titles not displaying properly when the report is output in csv format

I have a reporting services 2008 r2 report that I output to csv format, but the problem is that the headers for the columns are displaying like 'FirstName' when I want it to display like 'First Name' Is there a way to change that?
The csv output uses the control name for the output textbox. If you change the control name this will update. (I'm not sure that you can use spaces in control names though).