Completed
Last Updated: 28 Jun 2019 08:52 by ADMIN
Daniel
Created on: 21 Jan 2019 13:38
Category: Grid
Type: Bug Report
5
After upgrading to 2019.1.115 Export to XLSX throws an exception: Index was out of range

System.ArgumentOutOfRangeException
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

This error seems to happen if there is a GridTemplateColumn that has the Exportable property set to False.

4 comments
ADMIN
Attila Antal
Posted on: 28 Jun 2019 08:52
Seems that there is another scenario where this exception could occur while Exporting to Excel XLSX: Export to XLSX with unused ColumnGroup throws exception: Index was out of range. In case anybody comes across that issue, the workaround posted below in this article would serve as a temporary workaround.
ADMIN
Attila Antal
Posted on: 12 Feb 2019 08:32
Dear developers,

Good news! The issue with the Excel Export is now fixed and included in the LIB (Latest Internal Build) upload - Telerik_UI_for_ASP.NET_AJAX_2019_1_211_Dev_hotfix.zip. It can be downloaded from https://www.telerik.com/account/product-download?product=RCAJAX.  The Release notes for this nightly build can be found at - UI for ASP.NET AJAX 2019.1.211 (Nightly Build 2019/02/11)

Please check if the LIB version fixes the issue on your side and if there any side effects we would be grateful if you share them with us. The hotfix will be part of the upcoming R1 2019 SP1 release due on Feb 20, 2019 (next week) and we want to ensure it will be stable and is tested in more complex real-life cases.
ADMIN
Attila Antal
Posted on: 22 Jan 2019 12:15
We've made several testing and we found that the export fails if the last column in the columns collection has either the Visible property, the Display or the Exportable property set to false.

A viable workaround could be to add a GridRowIndicatorColumn to the end of the columns collection. This will not show up neither in the browser nor in the exported file.

<telerik:RadGrid runat="server" ID="RadGrid1">
    <MasterTableView>
        <Columns>
            <%-- Other columns --%>
            <telerik:GridRowIndicatorColumn></telerik:GridRowIndicatorColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

Another option would be to use GridTemplateColumn with 1px of Width. For that to take effect, set the TableLayout property of the MasterTableView to Fixed.

<telerik:RadGrid runat="server" ID="RadGrid2">
    <MasterTableView TableLayout="Fixed">
        <Columns>
            <%-- Other columns --%>
            <telerik:GridTemplateColumn>
                <HeaderStyle Width="1px" />
                <ItemTemplate></ItemTemplate>
            </telerik:GridTemplateColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>
ADMIN
Attila Antal
Posted on: 22 Jan 2019 08:24
We recognize this issue is critical to your business and we are working on fixing it quickly. In the meantime, please click on Follow to get notified about upcoming news. If a workaround is available, we will share it here.