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

Remove filter from the Exported XLSX file

2 Answers 271 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Subhashini
Top achievements
Rank 1
Subhashini asked on 08 Jun 2016, 09:23 PM

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 Answers, 1 is accepted

Sort by
0
Accepted
Eyup
Telerik team
answered on 13 Jun 2016, 11:36 AM
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.
0
Subhashini
Top achievements
Rank 1
answered on 13 Jun 2016, 06:14 PM

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

Tags
Grid
Asked by
Subhashini
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Subhashini
Top achievements
Rank 1
Share this question
or