
I'm exporting hierarchical grid to Excel.
The problem is that while exporting the grid it's loosing the formatting of the Cells like Background color which i have set in
ItemDataBound event depending upon some condition.But in export to excel its not get persited.
Is there any way to achive this?
.
Thanks.
6 Answers, 1 is accepted

Can you please provide the solution ASAP. As its urgent.
I believe it will be very helpful if you check out the following article which describes the requested functionality
Word/Excel Export (HTML-Based)
In addition, you could refer to the articles below for preserving appearance and images on PDF exporting:
Grid / Export to PDF
PDF Export
Greetings,
Eyup
the Telerik team

If we will use the below formatting,
RadGrid1.ExportSettings.Excel.Format = Telerik.Web.UI.
GridExcelExportFormat.ExcelML;
Then it will not call the the event,
protected void RadGrid1_ExportCellFormating(object source, ExcelExportCellFormattingEventArgs e)
We want to use "ExcelML" format as we are exporting Hierarchical Grid.
Please provide solution.
In such case, you will need to use the ExcelMLExportStylesCreated server event. Please check out the following demo and its related help topic to get a practical idea of the suggested approach:
Grid / Export to ExcelML
I hope this will prove helpful.
All the best,
Eyup
the Telerik team

Thanks for help. But I have certain conditions which i need to check before applying colors to item.
Like
if (item.OwnerTableView.Name.Equals("Task"))
{
if (item["BSD_COLOR"].Text == "R")
{
item[
"BASELINE_START_DATE"].BackColor = Color.Red;
}
else if (item["BSD_COLOR"].Text == "G")
{
item[
"BASELINE_START_DATE"].BackColor = Color.Green;
}
if (item["BFD_COLOR"].Text == "R")
{
item[
"BASELINE_FINISH_DATE"].BackColor = Color.Red;
}
else if (item["BFD_COLOR"].Text == "G")
{
item[
"BASELINE_FINISH_DATE"].BackColor = Color.Green;
}
}
if (item.OwnerTableView.Name.Equals("SubTask"))
{
item[
"BASELINE_START_DATE"].BackColor = GetColorForBSDSubTask(item["BASELINE_START_DATE"].Text, item["actual_start_date"].Text);
item[
"BASELINE_FINISH_DATE"].BackColor = GetColorForBFDSubTask(item["BASELINE_FINISH_DATE"].Text, item["ACTUAL_FINISH_DATE"].Text, item["ESTIMATED_COMPLETION_DATE"].Text);
}
like this. but in "RadGrid_
ExcelMLExportRowCreated(
object source, Telerik.Web.UI.GridExcelBuilder.GridExportExcelMLRowCreatedArgs e)" ,we are not able to get Items.
Please Suggest.
I am afraid there is no direct way to access the corresponding GridDataItem to the current RowElement in the mentioned server event. You will need to manually customize the cells' styles in accordance with their data values.
I have created a sample RadGrid web site to demonstrate the suggested approach. Please check out the attached application and try to implement it within your own project.
Greetings,
Eyup
the Telerik team