When I export a WebDataGrid that contains only a couple of thousand records, the export works fine. The export works for most lists. However, this particular set of data that I am trying to export has 6000 records, and results in an error traced to somewhere internal to the WebExcelExporter
The WebDataGrid is visible on the page, being populated in Page_Load by a dataset that is maintained in session cache. Both elements are next to each other in the DOM, within the same WebSplitterPane which is within an UpdatePanel.
I am using version 11.1.
Here are the definitions:
<ig:WebExcelExporter ID="WebExcelExporter1" runat="server" DownloadName="StreetList" DataExportMode="AllDataInDataSource"> </ig:WebExcelExporter> <ig:WebDataGrid ID="WebDataGrid1" runat="server" Visible="False" StyleSetName="IG" AutoGenerateColumns="False" Width="100%" Height="100%"> <Columns> <ig:BoundDataField DataFieldName="RouteNo" DataType="System.String" Key="RouteNo"> <Header Text="Route" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="StNum" DataType="System.String" Key="StNum"> <Header Text="StNum" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="StName" DataType="System.String" Key="StName"> <Header Text="StName" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Apt#" DataType="System.String" Key="Apt#"> <Header Text="Unit" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Zip" DataType="System.String" Key="Zip"> <Header Text="Zip" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Pub" DataType="System.String" Key="Pub"> <Header Text="Pub" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Freq" DataType="System.String" Key="Freq"> <Header Text="Freq" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Qty" DataType="System.String" Key="Qty"> <Header Text="Qty" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Vacation" DataType="System.String" Key="Vacation"> <Header Text="Vacation" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="RouteCardComment1" DataType="System.String" Key="RouteCardComment1"> <Header Text="RouteCardComment1" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="RouteCardComment2" DataType="System.String" Key="RouteCardComment2"> <Header Text="RouteCardComment2" /> </ig:BoundDataField> </Columns> <Behaviors> <ig:Filtering> </ig:Filtering> <ig:VirtualScrolling> </ig:VirtualScrolling> </Behaviors> </ig:WebDataGrid>
<ig:WebDataGrid ID="WebDataGrid1" runat="server" Visible="False" StyleSetName="IG" AutoGenerateColumns="False" Width="100%" Height="100%"> <Columns> <ig:BoundDataField DataFieldName="RouteNo" DataType="System.String" Key="RouteNo"> <Header Text="Route" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="StNum" DataType="System.String" Key="StNum"> <Header Text="StNum" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="StName" DataType="System.String" Key="StName"> <Header Text="StName" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Apt#" DataType="System.String" Key="Apt#"> <Header Text="Unit" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Zip" DataType="System.String" Key="Zip"> <Header Text="Zip" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Pub" DataType="System.String" Key="Pub"> <Header Text="Pub" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Freq" DataType="System.String" Key="Freq"> <Header Text="Freq" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Qty" DataType="System.String" Key="Qty"> <Header Text="Qty" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Vacation" DataType="System.String" Key="Vacation"> <Header Text="Vacation" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="RouteCardComment1" DataType="System.String" Key="RouteCardComment1"> <Header Text="RouteCardComment1" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="RouteCardComment2" DataType="System.String" Key="RouteCardComment2"> <Header Text="RouteCardComment2" /> </ig:BoundDataField> </Columns> <Behaviors> <ig:Filtering> </ig:Filtering> <ig:VirtualScrolling> </ig:VirtualScrolling> </Behaviors> </ig:WebDataGrid>
Here is the VB.Net codebehind for the export:
Protected Sub btnExporttoExcel_Click(sender As Object, e As System.EventArgs) Handles btnExporttoExcel.Click WebExcelExporter1.Export(WebDataGrid1) End Sub
Here is the error:
Server Error in '/TESTACISEATTLE' Application.-------------------------------------------------------------------------------- Index was outside the bounds of the array. 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.IndexOutOfRangeException: Index was outside the bounds of the array. Source Error: Line 364:Line 365: Protected Sub btnExporttoExcel_Click(sender As Object, e As System.EventArgs) Handles btnExporttoExcel.ClickLine 366: WebExcelExporter1.Export(WebDataGrid1)Line 367: End SubLine 368:End Class Source File: D:\Webfolders\mydistrict.net_dev\ReportStreetList.aspx.vb Line: 366 Stack Trace: [IndexOutOfRangeException: Index was outside the bounds of the array.] Infragistics.Documents.Excel.GenericElementHashSet`1.IncreaseCapacity() +546 Infragistics.Documents.Excel.GenericElementHashSet`1.AddIfItemDoesntExist(T element, T& existingElement) +459 Infragistics.Documents.Excel.GenericCachedCollection`1.FindOrAdd(T element, T& equivalentElement) +24 Infragistics.Documents.Excel.GenericCacheElement.FindExistingOrAddToCache(T newElement, GenericCachedCollection`1 collection) +104 Infragistics.Documents.Excel.WorksheetCellBlock.SetCellValueInternalHelper(WorksheetRow row, Int16 columnIndex, Object valueInternal, DataType& type, CellValue& cellValue) +229 Infragistics.Documents.Excel.WorksheetCellBlock.SetCellValueInternal(WorksheetRow row, Int16 columnIndex, Object newValueInternal, Boolean checkForBlockingValues) +316 Infragistics.Documents.Excel.WorksheetRow.SetCellValueInternal(Int16 columnIndex, Object valueInternal, Boolean checkForBlockingValues) +82 Infragistics.Documents.Excel.WorksheetRow.SetCellValue(Int32 columnIndex, Object value) +51 Infragistics.Web.UI.GridControls.WebExcelExporter.ExportCell(GridRecordItem item, WorksheetRow worksheetRow, Int32 rowIndex, Int32 columnIndex, String gridCssClass, String itemCssClass) +622 Infragistics.Web.UI.GridControls.WebExcelExporter.ExportRow(GridRecord gridRecord, Worksheet worksheet, Int32& rowIndex, Int32 columnOffset, Boolean hasHiddenCols, Int32 outlineLevel, Boolean hidden, String gridCssClass, String itemCssClass) +503 Infragistics.Web.UI.GridControls.WebExcelExporter.ExportGrid(WebDataGrid grid, Worksheet worksheet, Int32& rowIndex, Int32 columnOffset, Int32 outlineLevel) +2088 Infragistics.Web.UI.GridControls.WebExcelExporter.Export(WebDataGrid grid, Worksheet worksheet, Int32 rowOffset, Int32 columnOffset) +136 Infragistics.Web.UI.GridControls.WebExcelExporter.Export(WebDataGrid grid, Worksheet worksheet) +17 Infragistics.Web.UI.GridControls.WebExcelExporter.Export(WebDataGrid grid, Workbook workbook) +125 Infragistics.Web.UI.GridControls.WebExcelExporter.Export(WebDataGrid grid) +47 ReportStreetList.btnExporttoExcel_Click(Object sender, EventArgs e) in D:\Webfolders\mydistrict.net_dev\ReportStreetList.aspx.vb:366 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563 --------------------------------------------------------------------------------Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319
Index was outside the bounds of the array. 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.IndexOutOfRangeException: Index was outside the bounds of the array.
Source Error:
Line 364:Line 365: Protected Sub btnExporttoExcel_Click(sender As Object, e As System.EventArgs) Handles btnExporttoExcel.ClickLine 366: WebExcelExporter1.Export(WebDataGrid1)Line 367: End SubLine 368:End Class
Source File: D:\Webfolders\mydistrict.net_dev\ReportStreetList.aspx.vb Line: 366
Stack Trace:
[IndexOutOfRangeException: Index was outside the bounds of the array.] Infragistics.Documents.Excel.GenericElementHashSet`1.IncreaseCapacity() +546 Infragistics.Documents.Excel.GenericElementHashSet`1.AddIfItemDoesntExist(T element, T& existingElement) +459 Infragistics.Documents.Excel.GenericCachedCollection`1.FindOrAdd(T element, T& equivalentElement) +24 Infragistics.Documents.Excel.GenericCacheElement.FindExistingOrAddToCache(T newElement, GenericCachedCollection`1 collection) +104 Infragistics.Documents.Excel.WorksheetCellBlock.SetCellValueInternalHelper(WorksheetRow row, Int16 columnIndex, Object valueInternal, DataType& type, CellValue& cellValue) +229 Infragistics.Documents.Excel.WorksheetCellBlock.SetCellValueInternal(WorksheetRow row, Int16 columnIndex, Object newValueInternal, Boolean checkForBlockingValues) +316 Infragistics.Documents.Excel.WorksheetRow.SetCellValueInternal(Int16 columnIndex, Object valueInternal, Boolean checkForBlockingValues) +82 Infragistics.Documents.Excel.WorksheetRow.SetCellValue(Int32 columnIndex, Object value) +51 Infragistics.Web.UI.GridControls.WebExcelExporter.ExportCell(GridRecordItem item, WorksheetRow worksheetRow, Int32 rowIndex, Int32 columnIndex, String gridCssClass, String itemCssClass) +622 Infragistics.Web.UI.GridControls.WebExcelExporter.ExportRow(GridRecord gridRecord, Worksheet worksheet, Int32& rowIndex, Int32 columnOffset, Boolean hasHiddenCols, Int32 outlineLevel, Boolean hidden, String gridCssClass, String itemCssClass) +503 Infragistics.Web.UI.GridControls.WebExcelExporter.ExportGrid(WebDataGrid grid, Worksheet worksheet, Int32& rowIndex, Int32 columnOffset, Int32 outlineLevel) +2088 Infragistics.Web.UI.GridControls.WebExcelExporter.Export(WebDataGrid grid, Worksheet worksheet, Int32 rowOffset, Int32 columnOffset) +136 Infragistics.Web.UI.GridControls.WebExcelExporter.Export(WebDataGrid grid, Worksheet worksheet) +17 Infragistics.Web.UI.GridControls.WebExcelExporter.Export(WebDataGrid grid, Workbook workbook) +125 Infragistics.Web.UI.GridControls.WebExcelExporter.Export(WebDataGrid grid) +47 ReportStreetList.btnExporttoExcel_Click(Object sender, EventArgs e) in D:\Webfolders\mydistrict.net_dev\ReportStreetList.aspx.vb:366 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563
--------------------------------------------------------------------------------Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319
Two additional notes.
Theoretically, the above process would rule out that anything with the data was causing the error. However... on a whim...
Ok... so we have discovered that page size impacts the error, but not on all pages... So, I tried some different page sizes, and here is what I discovered:
So, this begs the question... What is the data in rows 1215-1220?
Here is a screenshot:
Looking at the raw data from SQL, there is nothing unique about these rows. The empty values in the columns to the right are nulls. There are two hidden columns, but both of those columns have only nulls or empty strings in them.
Hello Rob,
I created a support ticket on your behalf regarding this
CAS-69557-KNGGCK
I will link it to the development issue in order to be notified when the Service release is available.
Thank you both very much... looking forward to the next service release!
Also, what is the upper limit of rows that WebExcelExporter can export into a worksheet? Does the excel file version affect this count?
Thanks, - Rob
Yes. In Excel 97-2003, the limit on the number of rows was 2^16, or 65,536. In Excel 2007 and later, the limit is 2^20, or 1,048,576 rows.
Gotcha... I understand that these are the Excel limits.
I was just wondering if the WebExcelExporter has the same limits. WebExcelExporter will export a million rows in Excel 2007 mode?
Thanks Dave,
We do have people who download large datasets, which I presently force to a delimited format.
It would be really great to provide Excel as an option, and was wondering if you guys had tested the limits of the WebExcelExporter before I put it out there as a supported feature.
It sounds like internal testing hasn't been done, and I'll have to do it on this side, which I don't mind doing.
Thanks!
-Rob
Hi Rob,
I've never tried to export a million rows myself with the WebExcelExporter. If the Excel file can have that much, I would think it should work so long as the WorkBook object fits in memory and the stream can be sent down to download. If you do not know how to set the excel 2007 mode, put this on the exporter in the aspx.
WorkbookFormat="Excel2007"
If you have trouble exporting a million rows, let us know. It could indicate a problem in the control or framework.
-Dave