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

Exporting RadGrid to Excel questions

1 Answer 47 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Craig
Top achievements
Rank 2
Craig asked on 03 Oct 2012, 03:53 PM
Hello,

   I have a RadGrid that displays some dollar values.  On the screen, it needs to be displayed as "$00.00 USD" but when it is exported to excel, I need the cell to be "$00.00" (no currency type).  The reason is that if I export the "USD" it is not considered a numeric column and isn't very useful.  Is there any way to modify what is placed in the excel cell on a cell by cell basis?  Is there a way to export some columns and not others?  Can I export a non-displayed column? 

Thanks for any help you can provide!!

Craig.

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 04 Oct 2012, 04:40 AM
Hi,

You can set the currency format in ExportCellFormatting event as shown below.
C#:
protected void RadGrid1_ExportCellFormatting(object sender, ExportCellFormattingEventArgs e)
{
 if (e.FormattedColumn.UniqueName == "UniqueName")
 {
   e.Cell.Style["mso-number-format"] = "Currency";
 }
}
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
 if (e.CommandName == RadGrid.ExportToExcelCommandName)
 {
   RadGrid1.MasterTableView.GetColumn("UniqueName").Display = true;//showing the hidden columns
   RadGrid1.MasterTableView.GetColumn("UniqueName1").Display = false;//hiding the columns
 }
}

Thanks,
Princy.
Tags
General Discussions
Asked by
Craig
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Share this question
or