FIX: Error message when you try to export SQL Server 2005 reports to Excel: "Index out of range" (914398)



The information in this article applies to:

  • Microsoft SQL Server 2005 Standard Edition
  • Microsoft SQL Server 2005 Standard X64 Edition
  • SQL Server 2005 Standard Edition for Itanium-based Systems
  • Microsoft SQL Server 2005 Enterprise Edition
  • Microsoft SQL Server 2005 Enterprise X64 Edition
  • Microsoft SQL Server 2005 Enterprise Edition for Itanium Based Systems
  • Microsoft SQL Server 2005 Developer Edition

BUG #: 342 (SQL Hotfix)
Microsoft distributes Microsoft SQL Server 2005 fixes as one downloadable file. Because the fixes are cumulative, each new release contains all the hotfixes and all the security fixes that were included with the previous SQL Server 2005 fix release.
This article describes the following about this hotfix release:
  • The issues that are fixed by this hotfix package
  • The prerequisites for installing this hotfix package
  • Whether you must restart the computer after you apply this hotfix package
  • Whether this hotfix package is replaced by any other hotfix package
  • Whether you must make any registry changes after you apply this hotfix package
  • The files that are contained in this hotfix package

SYMPTOMS

When you try to export SQL Server 2005 reports to Microsoft Office Excel or to Microsoft Excel, you may receive an error message that resembles the following:
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

CAUSE

This problem occurs in the following scenario:
  • A report item is embedded in multiple nested containers. Some examples of report items are as follows:
    • Tables
    • Matrices
    • Lists
    • Charts
    • Text boxes
    • Images
    • Lines
    • Rectangles
    • Sub reports
    • Any other item in a report that displays data and graphical elements.
  • The embedded report item is hidden. A report item can be hidden by setting its Visible property to FALSE. A report item can also be hidden programmatically.
  • When the embedded report item is hidden, the Excel report renderer removes the UI space for that item. The Excel report renderer uses a Shrink algorithm to remove the UI space for hidden items.
  • The Excel report renderer uses an index to track the total count of items in the report. Before the hotfix is applied, the embedded report item is not included in the total count of items in the report.
  • When the Excel report renderer tries to look up the embedded report item by index number, the index number of the embedded report item is larger than the total count of items in the report. Therefore, the Excel report renderer throws an Index out of range error.

RESOLUTION

To resolve this problem, obtain the latest service pack for SQL Server 2005. For more information, click the following article number to view the article in the Microsoft Knowledge Base:

913090 A list of the bugs that have been fixed in SQL Server 2005 Service Pack 1

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section. This problem was first corrected in SQL Server 2005 Service Pack Service Pack 1.

MORE INFORMATION

When this problem occurs, a call stack trace is generated. The call stack trace resembles the following:
[Exception: An error occurred during rendering of the report.]
Microsoft.Reporting.WebForms.ServerReport.ServerUrlRequest(Boolean isAbortable, String url, Stream outputStream, String& mimeType, String& fileNameExtension) +489
Microsoft.Reporting.WebForms.ServerReport.InternalRender(Boolean isAbortable, String format, String deviceInfo, NameValueCollection urlAccessParameters, Stream reportStream, String& mimeType, String& fileNameExtension) +924
Microsoft.Reporting.WebForms.ServerReportControlSource.RenderReport(String format, String deviceInfo, NameValueCollection additionalParams, String& mimeType, String& fileExtension) +84
Microsoft.Reporting.WebForms.ExportOperation.PerformOperation(NameValueCollection urlQuery, HttpResponse response) +153
Microsoft.Reporting.WebForms.HttpHandler.ProcessRequest(HttpContext context) +75
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +154
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64
When this problem occurs, the log file in Report Server shows an exception stack. The exception stack resembles the following:
e ERROR: Reporting Services error Microsoft.ReportingServices.Diagnostics.Utilities.RSException: An error occurred during rendering of the report. ---> Microsoft.ReportingServices.ReportProcessing.WrapperReportRenderingException: An error occurred during rendering of the report. ---> Microsoft.ReportingServices.ReportRendering.ReportRenderingException: An error occurred during rendering of the report. ---> System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

at System.Collections.ArrayList.get_Item(Int32 index)
at Microsoft.ReportingServices.Rendering.ExcelRenderer.PosArray.get_Item(Int32 index)
at Microsoft.ReportingServices.Rendering.ExcelRenderer.ExcelRendererUtility.AdjustPositions(IPosArray posArray, IPos posStart, IPos posEnd, Double delta, Boolean horizontal)
at Microsoft.ReportingServices.Rendering.ExcelRenderer.MarkInformation.ResetHeight(Double delta)
at Microsoft.ReportingServices.Rendering.ExcelRenderer.ExcelRenderer.ProcessPage(Page page, ReportItemCollection riCollection, PageReportItems& firstPageReportItems, Context context, String language, MarkInformation parentMarkInfo, ArrayList& unresNamesInRIInfo, Hashtable& namesInContainer, FormulaContext formulaContext)
at Microsoft.ReportingServices.Rendering.ExcelRenderer.ExcelRenderer.CreatePages(ReportItemCollection collection, MarkInformation parentMarkInfo, Boolean& isPBSPropagated, Boolean hasLastPage, Boolean ignorePageBreaks, Context context, FormulaContext formulaContext, String language, PageReportItems& firstPageReportItems, PageLayout& firstPageLayout, PageCollection& pageCollection)
at Microsoft.ReportingServices.Rendering.ExcelRenderer.ExcelRenderer.PreProcessReportItemCollection(ReportItemCollection reportItemCollection, ReportItem container, MarkInformation markInfoOfContainer, Boolean ignorePageBreaks, Boolean hasContainerLastPage, Context context, FormulaContext formulaContextForContainer, String language, PageReportItems& firstPageReportItems, PageLayout& firstPageLayoutOfContainer)
at Microsoft.ReportingServices.Rendering.ExcelRenderer.ExcelRenderer.GetFirstPageLayoutOfRectangleOrSubReport(ReportItem reportItem, MarkInformation markInfoOfContainer, MarkInformation parentMarkInfo, ContainerStructure containerStructure, String language, Context context, PageReportItems& firstPageReportItems, ArrayList& unresNamesInRIInfo, Hashtable& namesInContainer)
at Microsoft.ReportingServices.Rendering.ExcelRenderer.ExcelRenderer.ProcessPage(Page page, ReportItemCollection riCollection, PageReportItems& firstPageReportItems, Context context, String language, MarkInformation parentMarkInfo, ArrayList& unresNamesInRIInfo, Hashtable& namesInContainer, FormulaContext formulaContext)
at Microsoft.ReportingServices.Rendering.ExcelRenderer.ExcelRenderer.CreatePages(ReportItemCollection collection, MarkInformation parentMarkInfo, Boolean& isPBSPropagated, Boolean hasLastPage, Boolean ignorePageBreaks, Context context, FormulaContext formulaContext, String language, PageReportItems& firstPageReportItems, PageLayout& firstPageLayout, PageCollection& pageCollection)
at Microsoft.ReportingServices.Rendering.ExcelRenderer.ExcelRenderer.PreProcessReportItemCollection(ReportItemCollection reportItemCollection, ReportItem container, MarkInformation markInfoOfContainer, Boolean ignorePageBreaks, Boolean hasContainerLastPage, Context context, FormulaContext formulaContextForContainer, String language, PageReportItems& firstPageReportItems, PageLayout& firstPageLayoutOfContainer)
at Microsoft.ReportingServices.Rendering.ExcelRenderer.ExcelRenderer.GetFirstPageLayoutOfRectangleOrSubReport(ReportItem reportItem, MarkInformation markInfoOfContainer, MarkInformation parentMarkInfo, ContainerStructure containerStructure, String language, Context context, PageReportItems& firstPageReportItems, ArrayList& unresNamesInRIInfo, Hashtable& namesInContainer)
at Microsoft.ReportingServices.Rendering.ExcelRenderer.ExcelRenderer.ProcessPage(Page page, ReportItemCollection riCollection, PageReportItems& firstPageReportItems, Context context, String language, MarkInformation parentMarkInfo, ArrayList& unresNamesInRIInfo, Hashtable& namesInContainer, FormulaContext formulaContext)
at Microsoft.ReportingServices.Rendering.ExcelRenderer.ExcelRenderer.CreatePages(ReportItemCollection collection, MarkInformation parentMarkInfo, Boolean& isPBSPropagated, Boolean hasLastPage, Boolean ignorePageBreaks, Context context, FormulaContext formulaContext, String language, PageReportItems& firstPageReportItems, PageLayout& firstPageLayout, PageCollection& pageCollection)
at Microsoft.ReportingServices.Rendering.ExcelRenderer.ExcelRenderer.PreProcessListContent(ListContent listContent, Int32 listContentIndex, Boolean& isPBSPropagated, Boolean hasListLastPage, PageReportItems& firstPageReportItems, MarkInformation markInfoList, PageLayout& firstPageLayoutOfList, PageCollection& pageCollection, FormulaContext formulaContextOfListContent, String language, Boolean ignorePageBreaks)
at Microsoft.ReportingServices.Rendering.ExcelRenderer.ExcelRenderer.PreProcessList(List list, MarkInformation markInfoOfList, MarkInformation parentMarkInfo, ContainerStructure listStructure, PageReportItems& firstPageReportItems, FormulaContext formulaContextInList, String language, Boolean& preserveBottomPad)
at Microsoft.ReportingServices.Rendering.ExcelRenderer.ExcelRenderer.GetFirstPageLayoutOfList(List list, MarkInformation markInfoOfList, MarkInformation parentMarkInfo, ContainerStructure listStructure, String language, PageReportItems& firstPageReportItems, ArrayList& unresNamesInRIInfo, Boolean& preserveBottomPad)
at Microsoft.ReportingServices.Rendering.ExcelRenderer.ExcelRenderer.ProcessPage(Page page, ReportItemCollection riCollection, PageReportItems& firstPageReportItems, Context context, String language, MarkInformation parentMarkInfo, ArrayList& unresNamesInRIInfo, Hashtable& namesInContainer, FormulaContext formulaContext)
at Microsoft.ReportingServices.Rendering.ExcelRenderer.ExcelRenderer.CreatePages(ReportItemCollection collection, MarkInformation parentMarkInfo, Boolean& isPBSPropagated, Boolean hasLastPage, Boolean ignorePageBreaks, Context context, FormulaContext formulaContext, String language, PageReportItems& firstPageReportItems, PageLayout& firstPageLayout, PageCollection& pageCollection)
at Microsoft.ReportingServices.Rendering.ExcelRenderer.ExcelRenderer.PreProcessReport(ReportItemCollection reportItemCollection)
For more information about software update terminology, click the following article number to view the article in the Microsoft Knowledge Base:

824684 Description of the standard terminology that is used to describe Microsoft software updates


Modification Type:MinorLast Reviewed:7/26/2006
Keywords:kbsql2005sp1fix kbBug kbfix kbtshoot kbQFE kbhotfixserver kbpubtypekc KB914398 kbAudITPRO kbAudDeveloper