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

Export to Excel missing column

6 Answers 144 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bogice
Top achievements
Rank 1
Bogice asked on 11 Jan 2010, 04:53 PM
Hi Telerik,
I have tried to export a RadGrid to excel format: with these setting: - in grid mastertableview: UseAllDataFields = true, in code behind : ExportOnlyData = true, ExportSettings.Excel.Fornat = GridExcelExportFormat.ExcelML.
The result is only 1 column is appear on my excel report. Is there any thing else i am missing?
Thank you.

6 Answers, 1 is accepted

Sort by
0
Bogice
Top achievements
Rank 1
answered on 11 Jan 2010, 05:13 PM
I figured out that i should set DataField of GridTemplateColumn to the DataItem of that column.
0
Daniel
Telerik team
answered on 11 Jan 2010, 05:17 PM
Hello Bogice,

Please post your RadGrid's declaration here. This way we will be able to provide an appropriate answer.

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.
0
Bogice
Top achievements
Rank 1
answered on 11 Jan 2010, 05:29 PM
Here is the aspx:

<telerik:RadGrid ID="grdWarranty" runat="server" AllowPaging="True" AllowSorting="True" 
    AutoGenerateColumns="False" GridLines="None" Skin="Default" Width="700px" PageSize="7" 
    OnNeedDataSource="grdWarranty_NeedDataSource" OnItemCommand="grdWarranty_ItemCommand" 
    OnItemCreated="grdWarranty_ItemCreated" ShowStatusBar="true"
    <MasterTableView Width="100%" UseAllDataFields="true" TableLayout="Fixed" DataKeyNames="CompanyID,LocationID,ObjectType,ObjectID"
        <RowIndicatorColumn> 
            <HeaderStyle Width="20px" /> 
        </RowIndicatorColumn> 
        <ExpandCollapseColumn> 
            <HeaderStyle Width="20px" /> 
        </ExpandCollapseColumn> 
        <Columns> 
            <telerik:GridTemplateColumn HeaderText="Name" DataField="ObjectName" SortExpression="ObjectName"
                <ItemTemplate> 
                    <asp:LinkButton ID="LinkButtonOpen" runat="server" CausesValidation="False" CommandName='<%# DataBinder.Eval(Container, "DataItem.ObjectType") %>' 
                        CommandArgument='<%# DataBinder.Eval(Container, "DataItem.ObjectID") %>' Text='<%# DataBinder.Eval(Container, "DataItem.ObjectName") %>' /> 
                    <asp:Label runat="server" ID="lblName" Visible="false" Text='<%# DataBinder.Eval(Container, "DataItem.ObjectName") %>'></asp:Label> 
                </ItemTemplate> 
            </telerik:GridTemplateColumn> 
            <telerik:GridBoundColumn HeaderText="Type" DataField="ObjectType"
            </telerik:GridBoundColumn> 
            <telerik:GridTemplateColumn HeaderText="Location" DataField="LocationName" SortExpression="LocationName"
                <ItemTemplate> 
                    <%# LocationDisp(DataBinder.Eval(Container, "DataItem.LocationName").ToString()) %> 
                </ItemTemplate> 
            </telerik:GridTemplateColumn> 
            <telerik:GridTemplateColumn HeaderText="Expires" DataField="ExpirationDate" SortExpression="ExpirationDate"
                <ItemTemplate> 
                    <%# DateString.GetDateValue(DataBinder.Eval(Container, "DataItem.ExpirationDate").ToString()).ToString("M/d/yyyy").Replace("1/1/1900", "") %> 
                </ItemTemplate> 
            </telerik:GridTemplateColumn> 
            <telerik:GridTemplateColumn HeaderText="# Days" SortExpression="ExpirationDate"
                <ItemTemplate> 
                    <%# GetExpiration(DataBinder.Eval(Container, "DataItem.ExpirationDate").ToString()) %> 
                </ItemTemplate> 
            </telerik:GridTemplateColumn> 
        </Columns> 
    </MasterTableView> 
    <PagerStyle AlwaysVisible="true" Mode="NumericPages" /> 
    <ClientSettings EnableAlternatingItems="true" EnableRowHoverStyle="true"
        <Scrolling AllowScroll="true" ScrollHeight="185px" UseStaticHeaders="true" /> 
    </ClientSettings> 
</telerik:RadGrid> 

and code behind:
grdWarranty.ExportSettings.Excel.Format = GridExcelExportFormat.ExcelML; 
grdWarranty.ExportSettings.ExportOnlyData = true
               grdWarranty.ExportSettings.IgnorePaging = true
                grdWarranty.ExportSettings.OpenInNewWindow = true
                grdWarranty.ExportSettings.FileName = "WarrantyList"
                grdWarranty.MasterTableView.ExportToExcel(); 

I noticed that my Location is in the last column when export? Did i set something wrong?
Thank you
0
Daniel
Telerik team
answered on 14 Jan 2010, 12:37 PM
Hello Bogice,

There is no problem with the columns order on my end. I created a runnable demo based on your code but I failed to reproduce this behavior. Please download the aforementioned project and let me know whether it works as expected on your end.

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.
0
khalid
Top achievements
Rank 1
answered on 27 Jul 2015, 03:29 PM

Hello,

 I am using same code as you given but still i am unable to export some columns to Excel. I have copies the column that is Exporting to Excel to another place and tried to Export it to Excel. But still it is not Exporting. Can you please tell me why? only few column are going to export to Excel and data comming for all columna from the same data source.

Thanks.

0
Konstantin Dikov
Telerik team
answered on 30 Jul 2015, 08:03 AM
Hello Khalid,

Can you please provide a simplified version of your RadGrid that replicates the issue, so we can test it locally. Additionally, please elaborate on the version that you are using and the Excel format that you are trying to export to.

I am looking forward to your reply.


Regards,
Konstantin Dikov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Bogice
Top achievements
Rank 1
Answers by
Bogice
Top achievements
Rank 1
Daniel
Telerik team
khalid
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or