Remove filter from the Exported XLSX file

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

    Posted 08 Jun Link to this post

    Hi,

    I have a radgrid with the following settings

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

    <CommandItemTemplate>
                                                                            <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" />
      </CommandItemTemplate>

    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
    Admin
    Eyup avatar
    3015 posts

    Posted 13 Jun 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.

    Regards,
    Eyup
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Subhashini
    Subhashini avatar
    35 posts
    Member since:
    Oct 2014

    Posted 13 Jun 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