RadGridView export to XLS with GridViewCommandColumn

1 Answer 166 Views
GridView
Tomáš
Top achievements
Rank 1
Iron
Tomáš asked on 25 May 2023, 07:02 AM

Hi,

I'm having a problem while exporting a GridView containing some GridViewCommandColumns to a XLS.

I get a FormatException error in Telerik.WinControls.GridView.dll on these columns.

The code I use for export:

GridViewSpreadExport spreadExporter = new GridViewSpreadExport(gridView);
spreadExporter.ExportChildRowsGrouped = true;
spreadExporter.HiddenColumnOption = Telerik.WinControls.UI.Export.HiddenOption.DoNotExport;
spreadExporter.HiddenRowOption = Telerik.WinControls.UI.Export.HiddenOption.DoNotExport;
SpreadExportRenderer exportRenderer = new SpreadExportRenderer();
spreadExporter.RunExport(sDialog.FileName, exportRenderer);

I don't necessarily need these columns in a XLS, so I tried to hide them before exporting, set some export properties and even set values:

gridView.Columns["column1"].IsVisible = false;
gridView.Columns["column1"].ExcelExportType = Telerik.WinControls.UI.Export.DisplayFormatType.None;

foreach (var row in gridView.Rows)
{
    row.Cells["column1"].Value = 1;
}

The only way a grid exports correctly is when GridViewCommandColumns are deleted from the grid.

Any idea what should I try? I use version 2021.2.511.40.

Thanks in advance.

 

Regards,

Tomáš

 

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 29 May 2023, 12:05 PM

Hello, Tomáš,

Following the provided information, I was unable to reproduce the issue you are facing. Please refer to the attached gif file illustrating the behavior on my end with the specified version (2021.2.511.40). I have attached my sample project. Please give it a try and see how it works on your end. Am I missing something? Could you please specify the exact steps how to reproduce the problem? What changes are necessary in the project to reproduce the experienced issue so I can investigate the precise case? Thank you in advance. 

I am looking forward to your reply.

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tomáš
Top achievements
Rank 1
Iron
commented on 30 May 2023, 07:41 AM

Hi Dess,

thank you for your reply and a sample project. Your project worked fine.

I had to upgrade Telerik components to version 2023.1.314.40. Now it is OK even in my application.

There had to be a bug somewhere, luckily it's gone now.

 

Regards,

Tomáš

 

 

 

Tags
GridView
Asked by
Tomáš
Top achievements
Rank 1
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or