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

Rad grid export to excel

3 Answers 73 Views
Grid
This is a migrated thread and some comments may be shown as answers.
jayanthi
Top achievements
Rank 1
jayanthi asked on 19 Jun 2013, 11:35 AM
Am using rad grid in web application.
Grid display rows with 3 colors (red,green,yellow)
While export to excel it shows the colors, but i need to add header rows programatically.
So i used  <Excel Format="ExcelML" />, but it display rows without colors.

1. How to achieve it while export to excel, i need rows with colors and header rows
2. Also i need to add header in each page

Help me

Thank you
Jayanthi

3 Answers, 1 is accepted

Sort by
0
jayanthi
Top achievements
Rank 1
answered on 21 Jun 2013, 04:57 AM
Any ideas?
It's very urgent.
0
Princy
Top achievements
Rank 1
answered on 07 Aug 2013, 01:34 PM
Hi Jayanthi,

Can you try using Excel Format="HTML"  and see if you are able to achieve this scenario.Please go through these documentation where its mentioned about adding styles and headers.
Excel Format (HTML-Based) and HTML-Based Export.

Thanks,
Princy
0
Osismii
Top achievements
Rank 1
answered on 09 Aug 2013, 08:51 AM
Hello,

I do not know if I understand your problem correctly but I think the solutions are as follows:

For you format ExcelML can use something like this:


protected void rgList_OnExcelMLExportStylesCreated(object source, GridExportExcelMLStyleCreatedArgs e)
       {

               foreach (StyleElement style in e.Styles)
               {
                   if (style.Id == "headerStyle")
                   {
                       style.InteriorStyle.Pattern = InteriorPatternType.Solid;
                       style.InteriorStyle.Color = System.Drawing.ColorTranslator.FromHtml("#A05D62");
                   }
                   if (style.Id == "alternatingItemStyle")
                   {
                       style.InteriorStyle.Pattern = InteriorPatternType.Solid;
                       style.InteriorStyle.Color = System.Drawing.ColorTranslator.FromHtml("#COLOR");
                   }
                   if (style.Id.Contains("itemStyle"))
                   {
                       style.InteriorStyle.Pattern = InteriorPatternType.Solid;
                       style.InteriorStyle.Color = System.Drawing.ColorTranslator.FromHtml("#COLOR");
                   }
               }

       }

For the other problem, and if your goal is to add a header to Excel you can use something like this:

protected void rgList_ExcelMLExportRowCreated(object sender, GridExportExcelMLRowCreatedArgs e)
        {
 
 
            if (e.RowType == GridExportExcelMLRowType.HeaderRow)
            {
                RowElement row1 = new RowElement();
                CellElement cell1 = new CellElement();
                cell1.MergeAcross = e.Row.Cells.Count - 1;
                cell1.Data.DataItem = "Your text gos here";
                row1.Cells.Add(cell1);
                e.Worksheet.Table.Rows.Insert(0, row1);
                e.Worksheet.AutoFilter.Range = e.Worksheet.AutoFilter.Range.Replace("R1", "R2");
 
            }
        }

I hope that your problems were these.
Tags
Grid
Asked by
jayanthi
Top achievements
Rank 1
Answers by
jayanthi
Top achievements
Rank 1
Princy
Top achievements
Rank 1
Osismii
Top achievements
Rank 1
Share this question
or