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

Export to Excel is not working

2 Answers 117 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jayashree
Top achievements
Rank 1
Jayashree asked on 15 Sep 2009, 07:15 AM
Hi,
 I have a problem in export to excel, while exporting the grid it exports only 3 columns out of 6 columns,the 3 columns which are all exporting is binded with datafield, and other 6 columns are binded with Eval.Bind.
I have attached my code also.
     <telerik:RadGrid ClientSettings-Resizing-AllowColumnResize="true" ClientSettings-Resizing-EnableRealTimeResize="true" 
                    AllowMultiRowSelection="false" ID="GrdProjectAudit" Width="100%" runat="server" 
                    OnItemCreated="GrdProjectAudit_ItemCreated" AllowPaging="True" AllowSorting="True" 
                    PageSize="8" AutoGenerateColumns="false" AlternatingItemStyle-Width="10%" GridLines="Vertical" 
                    Skin="ePASVista" EnableEmbeddedSkins="false" ItemStyle-Wrap="false" HeaderStyle-Wrap="true" 
                    OnNeedDataSource="GrdProjectAudit_NeedSource">  
                    <PagerStyle Mode="NumericPages" /> 
                    <ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True">  
                        <Resizing AllowColumnResize="true" ClipCellContentOnResize="true" EnableRealTimeResize="true" 
                            ResizeGridOnColumnResize="true" /> 
                        <Selecting AllowRowSelect="True" /> 
                    </ClientSettings> 
                    <ExportSettings IgnorePaging="true" FileName="Project_History" Excel-Format="ExcelML" 
                        OpenInNewWindow="true" ExportOnlyData="true">  
                    </ExportSettings> 
                    <MasterTableView GroupLoadMode="Client" CommandItemDisplay="Top" TableLayout="Fixed" 
                        Width="100%">  
                        <NoRecordsTemplate> 
                            <asp:Label ID="lblNRF" runat="server" Text="No Projects to display"></asp:Label> 
                        </NoRecordsTemplate> 
                        <Columns> 
                            <telerik:GridBoundColumn HeaderText="Old Status" DataField="Old Status" Display="true">  
                                <HeaderStyle HorizontalAlign="Center" /> 
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn HeaderText="New Status" DataField="New Status" Display="true">  
                                <HeaderStyle HorizontalAlign="Center" /> 
                            </telerik:GridBoundColumn> 
                            <telerik:GridTemplateColumn> 
                                <HeaderStyle Width="18%" HorizontalAlign="Center" /> 
                                <HeaderTemplate> 
                                    <table style="color: Black;" border="0" cellpadding="0" cellspacing="0" width="100%">  
                                        <tr> 
                                            <td align="center">  
                                                Customer Incentive  
                                                <table border="0" cellpadding="0" cellspacing="0" width="100%">  
                                                    <tr> 
                                                        <td style="border-top: solid 1px gray;">  
                                                            Old  
                                                        </td> 
                                                        <td style="border-top: solid 1px gray;">  
                                                            New  
                                                        </td> 
                                                    </tr> 
                                                </table> 
                                            </td> 
                                        </tr> 
                                    </table> 
                                </HeaderTemplate> 
                                <ItemTemplate> 
                                    <table style="color: Black;" border="0" cellpadding="0" cellspacing="0" width="100%">  
                                        <tr> 
                                            <td style="vertical-align: middle;">  
                                                <asp:Label ID="lblcustomer" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Old Customer Incentive") %>'></asp:Label> 
                                                &nbsp;  
                                            </td> 
                                            <td style="vertical-align: middle;">  
                                                <asp:Label ID="lblcustnew" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "New Customer Incentive") %>'></asp:Label> 
                                            </td> 
                                        </tr> 
                                    </table> 
                                </ItemTemplate> 
                            </telerik:GridTemplateColumn> 
                            <telerik:GridTemplateColumn> 
                                <HeaderStyle Width="17%" HorizontalAlign="Center" /> 
                                <HeaderTemplate> 
                                    <table style="color: Black;" border="0" cellpadding="0" cellspacing="0" width="100%">  
                                        <tr> 
                                            <td align="center">  
                                                SP Incentive  
                                                <table border="0" cellpadding="0" cellspacing="0" width="100%">  
                                                    <tr> 
                                                        <td style="border-top: solid 1px gray;">  
                                                            Old  
                                                        </td> 
                                                        <td style="border-top: solid 1px gray;">  
                                                            New  
                                                        </td> 
                                                    </tr> 
                                                </table> 
                                            </td> 
                                        </tr> 
                                    </table> 
                                </HeaderTemplate> 
                                <ItemTemplate> 
                                    <table style="color: Black;" border="0" cellpadding="0" cellspacing="0" width="100%">  
                                        <tr> 
                                            <td style="vertical-align: middle;">  
                                                <asp:Label ID="lblSp" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Old SP Incentive") %>'></asp:Label> 
                                                &nbsp;  
                                            </td> 
                                            <td style="vertical-align: middle;">  
                                                <asp:Label ID="lblSpnew" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "New SP Incentive") %>'></asp:Label> 
                                            </td> 
                                        </tr> 
                                    </table> 
                                </ItemTemplate> 
                            </telerik:GridTemplateColumn> 
                            <telerik:GridTemplateColumn> 
                                <HeaderStyle Width="18%" HorizontalAlign="Center" /> 
                                <HeaderTemplate> 
                                    <table style="color: Black;" border="0" cellpadding="0" cellspacing="0" width="100%">  
                                        <tr> 
                                            <td align="center">  
                                                Third Party Incentive  
                                                <table border="0" cellpadding="0" cellspacing="0" width="100%">  
                                                    <tr> 
                                                        <td style="border-top: solid 1px gray;">  
                                                            Old  
                                                        </td> 
                                                        <td style="border-top: solid 1px gray;">  
                                                            New  
                                                        </td> 
                                                    </tr> 
                                                </table> 
                                            </td> 
                                        </tr> 
                                    </table> 
                                </HeaderTemplate> 
                                <ItemTemplate> 
                                    <table style="color: Black;" border="0" cellpadding="0" cellspacing="0" width="100%">  
                                        <tr> 
                                            <td style="vertical-align: middle;">  
                                                <asp:Label ID="lblSp" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Old Third Party Incentive") %>'></asp:Label> 
                                                &nbsp;  
                                            </td> 
                                            <td style="vertical-align: middle;">  
                                                <asp:Label ID="lblSpnew" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "New Third Party Incentive") %>'></asp:Label> 
                                            </td> 
                                        </tr> 
                                    </table> 
                                </ItemTemplate> 
                            </telerik:GridTemplateColumn> 
                            <telerik:GridTemplateColumn HeaderText="Updated By" HeaderStyle-ForeColor="Black"   
                                ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">  
                                <ItemTemplate> 
                                    <div style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">  
                                        <asp:Label ID="lblCreatedBy" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Created By") %>' ToolTip='<%# DataBinder.Eval(Container.DataItem, "Created By") %>' /> 
                                    </div> 
                                </ItemTemplate> 
                            </telerik:GridTemplateColumn> 
                           <telerik:GridBoundColumn HeaderText="Updated On" DataField="Created On" Display="true">  
                                <HeaderStyle HorizontalAlign="Center" /> 
                            </telerik:GridBoundColumn> 
                        </Columns> 
                        <CommandItemTemplate> 
                            <div> 
                                <table width="100%" border="0" cellpadding="0" cellspacing="0">  
                                    <tr> 
                                        <td align="right">  
                                            <asp:Image ID="Imgexcel" Height="14" Width="14" ImageUrl="~/App_Themes/images/Excel-16.gif" 
                                                runat="server"></asp:Image>&nbsp;<asp:LinkButton Text="Export" ToolTip="Export" CausesValidation="false" 
                                                    OnClick="LnkBtnExcelImport_Click" ID="LnkBtnExcelImport" ForeColor="black" runat="server"></asp:LinkButton>&nbsp;  
                                            <%--<asp:Image ImageUrl="~/App_Themes/images/Refresh.gif" runat="server" ID="imgRefresh" /> 
                                                        <asp:LinkButton CommandName="Refresh" ToolTip="Refresh" ID="lnkRefresh" Text="Refresh" 
                                                            runat="server" ForeColor="Black"></asp:LinkButton>--%> 
                                        </td> 
                                    </tr> 
                                </table> 
                            </div> 
                        </CommandItemTemplate> 
                    </MasterTableView> 
                </telerik:RadGrid> 
Can any one help out in this please.

Thanks,
Jaishri

2 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 15 Sep 2009, 07:57 AM

Hello Jayashree,

If you set ExportSettings.ExportOnlyData to true for the grid the labels from your template columns will not be present in the resulting documentation. You should either set this property to false or use the approach from the second paragraph of this help topic to include the information from the template columns in the resulting Excel file.

Kind regards,

Sebastian
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
Jayashree
Top achievements
Rank 1
answered on 15 Sep 2009, 09:04 AM
Hi,

        Sorry .. i tried yours idea.. but i am not getting the result.. can u show me one sample of the same please, which would be helpfull for me.


Thanks,
Jaishri.S
Tags
General Discussions
Asked by
Jayashree
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Jayashree
Top achievements
Rank 1
Share this question
or