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

Issue With Export Excel from RadGrid

1 Answer 102 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Prasad
Top achievements
Rank 1
Prasad asked on 18 Sep 2008, 10:54 PM
Hi,

I am trying to export the data in the grid using Radgrid export excel feature. Export works fine. But when i trying to do custom formting the rows it is throwing error when opening the excel "Prorblem came up in the following area during load" dialog of excel shows.

Below is the code i am using for custom formating. I  found the same code in Radgrid help too. It is working at the sample project present online in Radcontros site. Any help would be appreciated.

protected void rgGrid_ExcelMLExportRowCreated(object source, Telerik.Web.UI.GridExcelBuilder.GridExportExcelMLRowCreatedArgs e)

{

 if (e.RowType == Telerik.Web.UI.GridExcelBuilder.GridExportExcelMLRowType.DataRow)
 {
 if (e.Row.Cells[5] != null && (e.Row.Cells[5].Data.DataItem).Equals("I")){
 e.Row.Cells[0].StyleValue = "InsertStyle";
 }

 if (e.Row.Cells[5] != null && (e.Row.Cells[5].Data.DataItem).Equals("U")){
 e.Row.Cells[0].StyleValue = "UpdateStype";
 }

 if (e.Row.Cells[5] != null && (e.Row.Cells[5].Data.DataItem).Equals("D")){
 e.Row.Cells[0].StyleValue = "DeleteStyle";
 }
 }

}

 

 

protected void rgGrid_ExcelMLExportStylesCreated(object source, Telerik.Web.UI.GridExcelBuilder.GridExportExcelMLStyleCreatedArgs e){

    foreach (Telerik.Web.UI.GridExcelBuilder.StyleElement style in e.Styles){
      if (style.Id == "headerStyle"){
 style.FontStyle.Bold = true;
        style.FontStyle.Color = System.Drawing.Color.Gainsboro;
         style.InteriorStyle.Color = System.Drawing.Color.Wheat;
        style.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.InteriorPatternType.Solid;

        }
         else if (style.Id == "itemStyle")
         {
          style.InteriorStyle.Color = System.Drawing.Color.WhiteSmoke;
          style.InteriorStyle.Pattern =     Telerik.Web.UI.GridExcelBuilder.InteriorPatternType.Solid;
       }
 else if (style.Id == "alternatingItemStyle")
 {
 style.InteriorStyle.Color = System.Drawing.Color.LightGray;
 style.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.InteriorPatternType.Solid;
 }

    }

    Telerik.Web.UI.GridExcelBuilder.StyleElement myStyle = new Telerik.Web.UI.GridExcelBuilder.StyleElement("InsertStyle");
    myStyle.FontStyle.Bold = true;
    myStyle.FontStyle.Italic = true;
    myStyle.InteriorStyle.Color = System.Drawing.Color.Gray;
    myStyle.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.InteriorPatternType.Solid;
    e.Styles.Add(myStyle);

    Telerik.Web.UI.GridExcelBuilder.StyleElement upStyle = new Telerik.Web.UI.GridExcelBuilder.StyleElement("UpdateStyle");
    upStyle.FontStyle.Bold = true;
    upStyle.FontStyle.Italic = true;
    upStyle.InteriorStyle.Color = System.Drawing.Color.Aqua;
    upStyle.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.InteriorPatternType.Solid;
    e.Styles.Add(upStyle);

    Telerik.Web.UI.GridExcelBuilder.StyleElement delStyle = new Telerik.Web.UI.GridExcelBuilder.StyleElement("DeleteStyle");
    delStyle.FontStyle.Bold = true;
    delStyle.FontStyle.Italic = true;
    delStyle.InteriorStyle.Color = System.Drawing.Color.Brown;
    delStyle.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.InteriorPatternType.Solid;
    e.Styles.Add(delStyle);

}

1 Answer, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 23 Sep 2008, 06:55 AM
Hi Prasad,

Will it be convenient for you to open a regular support ticket and send us small runnable project which replicates the problem? We will test it locally and advise you further.

All the best,
Maria Ilieva
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Prasad
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Share this question
or