Exporting To ExcelML - index out of range problem

7 posts, 0 answers
  1. Ahmet Özgür
    Ahmet Özgür avatar
    37 posts
    Member since:
    Jul 2009

    Posted 11 Aug 2009 Link to this post

    Hi,

    I have a grid control which has some data. I want to export to data to excelML. I have read your demo (http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/exporting/defaultcs.aspx) and applied it. But could not resolve a problem. When it enters the function:

    protected void RadGridOrders_ExcelMLExportRowCreated(object source, Telerik.Web.UI.GridExcelBuilder.GridExportExcelMLRowCreatedArgs e) 
            { 
                if (e.RowType == Telerik.Web.UI.GridExcelBuilder.GridExportExcelMLRowType.DataRow) 
                { 
                    if (e.Row.Cells[0] != null && ((string)e.Row.Cells[0].Data.DataItem).Contains("U")) 
                    { 
                        e.Row.Cells[0].StyleValue = "MyCustomStyle"
                    } 
                } 
            } 


    It gives the error "index out of range". There e.Row.Cells.Count is always zero. But when i try to export it to just EXCEL there is no problem. Below is my Grid.

                    <telerik:RadGrid ID="RadGridOrders" runat="server" AllowPaging="True" 
                    Width="95%" OnExcelMLExportStylesCreated="RadGridOrders_ExcelMLExportStylesCreated" 
                OnExcelMLExportRowCreated="RadGridOrders_ExcelMLExportRowCreated" 
                        DataSourceID="DataSourceOrders" GridLines="None"
                        <ExportSettings ExportOnlyData="True" FileName="SatışRaporları"  
                            IgnorePaging="True"
                        </ExportSettings> 
                        <MasterTableView Width="100%" AutoGenerateColumns="False"
                            <Columns> 
                                <telerik:GridBoundColumn DataField="CalculatedCargoPrice"  
                                    DataType="System.Decimal" HeaderText="CalculatedCargoPrice" ReadOnly="True"  
                                    SortExpression="CalculatedCargoPrice" UniqueName="CalculatedCargoPrice"
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn DataField="CalculatedItemPrice"  
                                    DataType="System.Decimal" HeaderText="CalculatedItemPrice" ReadOnly="True"  
                                    SortExpression="CalculatedItemPrice" UniqueName="CalculatedItemPrice"
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn DataField="NameSurname" HeaderText="NameSurname"  
                                    ReadOnly="True" SortExpression="NameSurname" UniqueName="NameSurname"
                                </telerik:GridBoundColumn> 
                            </Columns> 
                        </MasterTableView> 
                    </telerik:RadGrid> 

    I am using LinqDataSource while populating the grid.

    Regards.
  2. Daniel
    Admin
    Daniel avatar
    4945 posts

    Posted 11 Aug 2009 Link to this post

    Hello Ahmet,

    I recommend you either set UseAllDataFields to your table view:
    <MasterTableView UseAllDataFields="true" ... 

    or set EnableLinqExpressions="false"
    <telerik:RadGrid  
       ID="RadGrid1"  
       EnableLinqExpressions="false"  
       runat="server"  
       ... 

    Regards,
    Daniel
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ahmet Özgür
    Ahmet Özgür avatar
    37 posts
    Member since:
    Jul 2009

    Posted 12 Aug 2009 Link to this post

    Thank you for your reply. Your suggestions solved my problem.
  5. Mark Galbreath
    Mark Galbreath avatar
    171 posts
    Member since:
    Jul 2009

    Posted 20 Nov 2009 Link to this post

    Given that documentation doesn't exist or sucks, it would be much more helpful for those of us pouring over these posts in search of answers if you would explain WHY those solutions work.
  6. Daniel
    Admin
    Daniel avatar
    4945 posts

    Posted 20 Nov 2009 Link to this post

    Dear Mark,

    I noticed that you posted your feedback about the documentation in many forum threads. Could you please stick to the following one so we can track our communication easier? As I promised, we will upload the updated versions of the export-related help topics with the next release of RadControls for ASP.NET AJAX. The old documentation is temporary unavailable since we are performing a major rewrite/rework on the old topics. In the meantime, I will gladly answer your questions about this functionality.

    As to the UseAllDataFields property:
    It should be used when exporting to ExcelML format and binding to data sources like array, ArrayList, custom objects, etc. RadGrid needs this property to retrieve all properties from the data source in the aforementioned scenario. Otherwise it won't be able to properly construct the export output - having this setting ensures that RadGrid will extract the values from your custom objects.

    Thank you for your understanding.

    Regards,
    Daniel
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  7. Mark Galbreath
    Mark Galbreath avatar
    171 posts
    Member since:
    Jul 2009

    Posted 20 Nov 2009 Link to this post

    Thank you for the explanations, Daniel.  In all the posts I have been asking about documentation, your reply is the first to address the lack of d/l current docs.  I appreciate that.

    Second, does the UseAllDataFields enumeration apply to dynamically-created queries  where the data fields are not known in advance?
  8. Daniel
    Admin
    Daniel avatar
    4945 posts

    Posted 23 Nov 2009 Link to this post

    Hello Mark,

    No, its use is datatype-dependent - the approach doesn't play role. In your scenario, it is probably the simple data binding that is causing the exception.

    Best regards,
    Daniel
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017