This is a migrated thread and some comments may be shown as answers.

Exporting To ExcelML - index out of range problem

6 Answers 108 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ahmet Özgür
Top achievements
Rank 1
Ahmet Özgür asked on 11 Aug 2009, 11:59 AM
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.

6 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 11 Aug 2009, 04:49 PM
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.
0
Ahmet Özgür
Top achievements
Rank 1
answered on 12 Aug 2009, 05:20 AM
Thank you for your reply. Your suggestions solved my problem.
0
Mark Galbreath
Top achievements
Rank 2
answered on 20 Nov 2009, 03:04 PM
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.
0
Daniel
Telerik team
answered on 20 Nov 2009, 04:21 PM
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.
0
Mark Galbreath
Top achievements
Rank 2
answered on 20 Nov 2009, 05:24 PM
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?
0
Daniel
Telerik team
answered on 23 Nov 2009, 03:15 PM
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.
Tags
Grid
Asked by
Ahmet Özgür
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Ahmet Özgür
Top achievements
Rank 1
Mark Galbreath
Top achievements
Rank 2
Share this question
or