Sql – Reporting Services 2005: Attempt to export to Excel gives “Object reference not set to an instance of an object.” error

reporting-servicessql server

I have a moderately complex report consisting of a lot of subreports.

One particular one is causing an issue: if you run it standalone, it works fine. If you integrate it as a subreport, it refuses to allow you to export to Excel format (from Preview), with the following error:

An error occurred during local report processing.
An error occurred during rendering of the report.
An error occurred during rendering of the report.
Object reference not set to an instance of an object.

Producing to any other format works fine. Most of my Googling thus far has said "Reinstall Reporting Services", which I really don't want to do (I reinstalled for a previous issue, and it took me a good day or so to get everything happy again – possibly more), especially given it's not a guaranteed fix.

I don't know if it's significant, but the reports do make us of Dundas Charts, which may make it more difficult to parse.

Anyone know a better solution?

Update:

When I try Exporting to Excel on the report server, it gives me this:

Object reference not set to an instance of an object. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Exception: Object reference not set to an instance of an object.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace: 


[Exception: Object reference not set to an instance of an object.]

[Exception: An error occurred during rendering of the report.]

[Exception: An error occurred during rendering of the report.]
   Microsoft.Reporting.WebForms.ServerReport.ServerUrlRequest(Boolean isAbortable, String url, Stream outputStream, String& mimeType, String& fileNameExtension) +520
   Microsoft.Reporting.WebForms.ServerReport.InternalRender(Boolean isAbortable, String format, String deviceInfo, NameValueCollection urlAccessParameters, Stream reportStream, String& mimeType, String& fileNameExtension) +936
   Microsoft.Reporting.WebForms.ServerReport.Render(String format, String deviceInfo, NameValueCollection urlAccessParameters, Stream reportStream, String& mimeType, String& fileNameExtension) +28
   Microsoft.Reporting.WebForms.ServerReportControlSource.RenderReport(String format, String deviceInfo, NameValueCollection additionalParams, String& mimeType, String& fileExtension) +85
   Microsoft.Reporting.WebForms.ExportOperation.PerformOperation(NameValueCollection urlQuery, HttpResponse response) +143
   Microsoft.Reporting.WebForms.HttpHandler.ProcessRequest(HttpContext context) +152
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

Best Answer

I ran into the same issue with the below statement. Everything works fine as expected except when exporting to excel.

=iif(ReportItems!textbox343.Value>ReportItems!textbox344.Value or ReportItems!textbox346.Value>ReportItems!textbox347.Value,"Yes","No")

Here is the fix. Added braces and voila voodoo magic it works.

=iif((ReportItems!textbox343.Value>ReportItems!textbox344.Value) or (ReportItems!textbox346.Value>ReportItems!textbox347.Value),"Yes","No")