in

jetlounge

the minty fresh blog that whitens your teeth!


Syndication


Reporting Services Report will not Export to Excel

by David Leibowitz | December 8, 2007 | Comments: 0

You may receive the error "Stack Empty" when trying to export your SQL Reporting Services report to Excel, while all other export methods work.

This issue that causes this may be a divide by zero formula somewhere in your report.
The deeper issue is how SSRS handles 0's in the divisors, and more importantly how it handles IIF statements.

Typically, you might start with the following formula:

>=ReportItems!A.Value/ReportItems!B.Value

But you'll soon grow irritated with the #Error that shows up on your report output everytime B is a zero. So you try to enhance your formula with the following:

=IIF(ReportItems!B.Value = 0,0,ReportItems!A.Value/ReportItems!B.Value)

All is still not well in the world because you're now cooking with VB, and in VB BOTH sides of the conditional statement are processed. Which means even if B is evaluated to 0, the division formula will still be processed and you are left with a #Error.

Ok, so what does this have to do with the "Stack Empty" issue? I don't know, but even though the report outputs to HTML and PDF, for some reason it rears its' ugly head when you attempt to export to Excel.

So now we have to clean up that formula, making it VB friendly and to ensure that you can export to Excel. Since both sides of the equation are evaluated, the following does the trick:

=IIF(ReportItems!B.Value<>0, ReportItems!A.Value/IIF(ReportItems!B.Value<>0, ReportItems!B.Value, 1),0)

We basically trick the formula into always evaluating a valid division by tossing in the extra IIF statement and the value of 1 if false (which of course will never occur).

This makes for a more pleasing report with 0's instead of #Error's, and allows the report to export to Excel without issue.

 

del.ico.us digg this technorati BlinkList Furl reddit DotNetKicks google! live Facebook Stumble Upon Yahoo!



Comments

No Comments

Leave a Comment

(required)  
(optional)
(required)  
Add
Powered by Community Server (Non-Commercial Edition), by Telligent Systems