Export to Excel missing column

7 posts, 0 answers
  1. Bogice
    Bogice avatar
    30 posts
    Member since:
    Dec 2009

    Posted 11 Jan 2010 Link to this post

    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.
  2. Bogice
    Bogice avatar
    30 posts
    Member since:
    Dec 2009

    Posted 11 Jan 2010 Link to this post

    I figured out that i should set DataField of GridTemplateColumn to the DataItem of that column.
  3. Daniel
    Admin
    Daniel avatar
    4949 posts

    Posted 11 Jan 2010 Link to this post

    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.
  4. Bogice
    Bogice avatar
    30 posts
    Member since:
    Dec 2009

    Posted 11 Jan 2010 Link to this post

    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
  5. Daniel
    Admin
    Daniel avatar
    4949 posts

    Posted 14 Jan 2010 Link to this post

    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.
  6. khalid
    khalid avatar
    7 posts
    Member since:
    Jul 2015

    Posted 27 Jul 2015 in reply to Daniel Link to this post

    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.

  7. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    2448 posts

    Posted 30 Jul 2015 Link to this post

    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
Back to Top