Remove filter from the Exported XLSX file

3 posts, 1 answers
  1. Subhashini
    Subhashini avatar
    35 posts
    Member since:
    Oct 2014

    Posted 08 Jun 2016 Link to this post


    I have a radgrid with the following settings

      <ExportSettings IgnorePaging="true" OpenInNewWindow="true" HideStructureColumns="true">
                                                                        <Excel Format="Xlsx" DefaultCellAlignment="Left" />                                                                    

                                                                            <asp:Button ID="btnShowAll" runat="server" Text="Clear Filter" CssClass="fa fa-refresh"
                                                                                AlternateText="Show All" ToolTip="Clear filters" CommandName="InitShowAll" />
                                                                            <asp:Button ID="btnExport" runat="server" Text="Export" CssClass="fa fa-refresh"
                                                                                AlternateText="Export" ToolTip="Export" CommandName="InitExport" />

    The issue is, I couldn't remove the filter row from the exported xlsx file. Even with ExportOnlyData = true the filter row data is visible. 

    I also tried filterItem.Visible = false. Sill no luck.

  2. Answer
    Eyup avatar
    4081 posts

    Posted 13 Jun 2016 Link to this post

    Hello Subhashini,

    Since you've enabled the IgnorePaging property, you can use the following approach to achieve this requirement:
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
        if (e.Item is GridFilteringItem && RadGrid1.IsExporting)
            GridFilteringItem filterItem = (GridFilteringItem)e.Item;
            filterItem.Visible = false;

    That should do the trick.

    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. Subhashini
    Subhashini avatar
    35 posts
    Member since:
    Oct 2014

    Posted 13 Jun 2016 in reply to Eyup Link to this post

    Thank you, Eyup. That fixed the problem. Also, to remove the empty line above the header in xlsx file, which represents the command buttons, i did the same.

    If (TypeOf e.Item Is GridCommandItem) Then
                Dim cmdItem As GridCommandItem = CType(e.Item, GridCommandItem)

                If rgTable.IsExporting Then

                    cmdItem.Visible = False
                End If
            End If

Back to Top