Do not export ColumnGroups to Excel

2 Answers 51 Views
Grid
Fabio
Top achievements
Rank 1
Iron
Iron
Fabio asked on 20 Dec 2023, 03:58 PM
Hello,

I would like not to export a ColumnGroups to Excel, if I simply make the columns that are part of the column group invisible it presents an error.

I really wish I didn't have ColumnGroups, as it doesn't make sense in my spreadsheet.

Thank you very much in advance

2 Answers, 1 is accepted

Sort by
0
Zach
Top achievements
Rank 1
Iron
answered on 24 Dec 2023, 10:06 PM

https://docs.telerik.com/devtools/aspnet-ajax/api/server/telerik.web.ui/gridboundcolumn#exportable

 

Try setting the Exportable value of the column to false. Exportable is a property of GridBoundColumn and will be available on all telerik grid columns.

0
Attila Antal
Telerik team
answered on 25 Dec 2023, 09:00 AM

Hello Fabio,

If you wish to exclude a column from the exported file, you can set the Exportable property to false as suggested by Zach.

To exclude the ColumnGroups, you can attach the ItemCommand event to the Grid and capture the Export Command. When this command is triggered, try clearing the ColumnGroups and rebinding the Grid.

Example

protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    RadGrid grid = (RadGrid)sender;

    if(e.CommandName == RadGrid.ExportToExcelCommandName)
    {
        grid.MasterTableView.ColumnGroups.Clear();
        grid.MasterTableView.Rebind();
    }
}

 

Regards,
Attila Antal
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Telerik family, check out our getting started resources
Tags
Grid
Asked by
Fabio
Top achievements
Rank 1
Iron
Iron
Answers by
Zach
Top achievements
Rank 1
Iron
Attila Antal
Telerik team
Share this question
or