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

[Solved] how to select some columns to export?

2 Answers 425 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jingying
Top achievements
Rank 1
Jingying asked on 19 Jun 2009, 06:12 PM
The export to excel works fine for me.

but if i have 3 columns in my RadGridView, how do i export only the 2 columns?
If i remove the last column, that will be removed from the grid instead.
I only want to remove the last column for export purpose only.

thanks.

2 Answers, 1 is accepted

Sort by
0
Accepted
Hristo Deshev
Telerik team
answered on 22 Jun 2009, 10:41 AM
Hi Jingying,

I recommend that instead of removing your columns, you make them invisible, and then revert that change after the export. Here's a small sample:

var hiddenColumns = new[] { "Age" }; 
foreach (var columnName in hiddenColumns) 
    this.RadGridView1.Columns[columnName].IsVisible = false
 
string content = GetExportedContent(); 
 
foreach (var columnName in hiddenColumns) 
    this.RadGridView1.Columns[columnName].IsVisible = true


All the best,
Hristo Deshev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Jingying
Top achievements
Rank 1
answered on 24 Jun 2009, 05:20 PM
That works. Thanks a lot.
Tags
GridView
Asked by
Jingying
Top achievements
Rank 1
Answers by
Hristo Deshev
Telerik team
Jingying
Top achievements
Rank 1
Share this question
or