radgridview export to excel skip columns

1 Answer 37 Views
GridView
Roger
Top achievements
Rank 2
Iron
Iron
Iron
Roger asked on 12 Jan 2022, 02:30 PM

I have a winform application with several radgridviews.  I have added export functionality, but do not see how to skip a column when exporting.

 

I did some research but nothing I found specifically shows / code examples of how this can be done in winform.

Here is my code.   

 GridViewSpreadExport spreadExporter = new GridViewSpreadExport(gv);

                spreadExporter.HiddenColumnOption = Telerik.WinControls.UI.Export.HiddenOption.DoNotExport;
                spreadExporter.ExportVisualSettings = true;
                SpreadExportRenderer exportRenderer = new SpreadExportRenderer();

                spreadExporter.RunExport(filename, exportRenderer);

 

I did try this:

radGridView1.Columns[0].ExcelExportType = Telerik.WinControls.UI.Export.DisplayFormatType.None;

and then calling the above code, but the column still shows up.

 

Why isn't there a simple property on the column ShowInExport we can set to True/False?

 

Thanks,

 

Roger

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 13 Jan 2022, 05:21 AM

Hi, Roger,

Indeed, the HiddenColumnOption property defines whether hidden columns will be exported. If you set it to DoNotExport, the exporter will not export hidden columns.

I have prepared a sample project for your reference. Please give it a try and see how it works on your end.

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Roger
Top achievements
Rank 2
Iron
Iron
Iron
commented on 13 Jan 2022, 01:40 PM

Dess,

This is a hidden column, I am wanting to NOT export a shown column.  I have a "Select" button column in my grid and when exporting I don't want this column exported.

I mistakenly thought you could hide a column then export and it would not be exported.

Thanks,

Roger

Dess | Tech Support Engineer, Principal
Telerik team
commented on 14 Jan 2022, 08:13 AM

Hi, Roger,

In order to skip a visible column from exporting, it would be necessary to hide it just before the export action is called and then make this column visible again. An alternative approach is to populate a dummy grid with the desired columns and export his dummy grid.

Feel free to use this approach which suits your requirements best.

Tags
GridView
Asked by
Roger
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or