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

Exporting to Excel Show and Hide column in row

1 Answer 134 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 23 Feb 2012, 11:24 PM
I have a RadGrid that shows or hides data in a certain row based on some logic in my RadGrid1_ItemDataBound method. 

I am trying to show the column and only certain rows on the export.

RadGrid
First Name   MVP
Fred             Yes
John             No
Bill
Stan             Yes
Jack             Yes

Export to Excel
First Name   MVP
Fred             Yes
John             No
Bill                Yes
Stan             Yes
Jack             Yes

As you can see I can hide "Yes" in the codebehind of the RadGrid1_ItemDataBind method, but it appears in the Export.

How can I get "Yes" to NOT appear in the export to excel?

protected void ButtonExcel_Click(object sender, System.EventArgs e)
   {
      ConfigureExport();
      RadGrid Grid1 = (RadGrid)Page.Master.FindControl("Main").FindControl("RadGrid1");
      Grid1.MasterTableView.GetColumn("mvp").Display = true;
      // Logic here to hide certain data in the based on the MVP value
      Grid1.MasterTableView.ExportToExcel();
   }


1 Answer, 1 is accepted

Sort by
0
Richard
Top achievements
Rank 1
answered on 27 Feb 2012, 05:47 PM
Michael:

Take a look at the Rad Grid Export to Excel issue forum thread. You should be able to modify the code provided by Shinu that uses the RadGrid_ExportCellFormatting event to conditionally hide column values in the export.

Hope this helps!
Tags
Grid
Asked by
Mike
Top achievements
Rank 1
Answers by
Richard
Top achievements
Rank 1
Share this question
or