When you make a report in Reporting Services, you often want to export it to Excel. Reporting Services quite often messes up the layout. For example, it often inserts columns that do not belong there, and you often get rounding problems.
Problem 1: columns are inserted
After you have exported a report from your Report Manager to Excel, you often want to do calculations with it. The problem is that Reporting Services often inserts columns, which makes it hard to do calculations.
The cause is the use of Report Items, for example in the header of your report. You may have a report title in your header, for example.
You will see that Excel splits the columns exactly where the Report Item ends. So in the example above, Excel inserts an extra column where the arrow is.
The fix is to make sure that the end of the Report Items falls exactly on a column split of, for example, a table, as in the picture below.
Problem 2: I get more digits after the decimal point than I specified
In the “format” field of a cell you can set what the output of a cell should look like. You use ‘c’ for output with a euro sign (currency), D2 for 2 decimals and P2 for a percentage with 2 digits. Say you enter P2 for a cell and the value of this cell is 0.4222. Then the output is “42.22%”, because we said we wanted 2 digits after the decimal point. When we then export the result to Excel, we often see that there are suddenly 3 digits after the decimal point! This is because Excel does not look at the P2 you set, but at the result of the dataset.
The fix is to Round in the cell or in the dataset. If we want the number with 2 digits after the decimal point, we have to Round to 4 digits after the decimal point (otherwise you get 0.42 and it rounds to 42%). You Round with the following Expression: =Round(Fiels!Omzet.Value,4)
Of course you can also do this in your dataset. Just be careful not to get rounding differences when you then use this number in calculations.
Frequently asked questions
Why does SSRS insert extra columns when I export to Excel?
The cause is Report Items, for example a report title in the header. Excel splits the columns exactly where the Report Item ends. That creates an extra column.
How do I prevent extra columns in an SSRS export to Excel?
Make sure the end of the Report Items falls exactly on a column split of, for example, a table. Then Excel does not insert an extra column.
Why do I get more decimals in Excel than I specified in SSRS?
With format P2, SSRS shows 0.4222 as 42.22%. After the export, Excel often shows more digits after the decimal point. The fix is to Round the value.
How do I round a value for an export to Excel in Reporting Services?
Use =Round(Fields!Omzet.Value,4) in the cell, or round in the dataset. For a percentage with 2 digits, you round to 4 digits. Watch out for rounding differences in calculations.
Which formats do I use in the format field of an SSRS cell?
Use c for an amount of money (currency), D2 for 2 decimals and P2 for a percentage with 2 digits.



Comments
Related blogs
The selected report is not ready for viewing
Passing a multi-value parameter to a drillthrough report
Divide by zero SSRS / division by 0 #error