locked
Exporting from RadGrid to Excel - multiple cell problem RRS feed

  • Question

  • User-1324178819 posted

    I have a situation where my RadGrid has some rows Containing multiple rows

    radgrid

     When I export this using RadGrid's export functionality, I see multiple cells used for 1 cell 

    Thursday, December 27, 2012 9:58 AM

All replies

  • User-1716253493 posted
    what i know rg has export feature, you dont need export manualy like gv. You can export rg to many format. See documentasion. demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/exporting/defaultcs.aspx
    Thursday, December 27, 2012 10:22 AM
  • User-1324178819 posted

     <ExportSettings IgnorePaging="True" HideStructureColumns="true" ExportOnlyData="True">
                        </ExportSettings>

     ShowExportToExcelButton="True"

    I use these values with RadGrid and when I export to Excel, it generates a separate cell for each row (which I cant leave like that)

    Thursday, December 27, 2012 10:36 AM
  • User3866881 posted

    Hi,

    Considering it that this belongs to a 3-rd party control tool of Telerik, I'm afraid Microsoft cannot do much comments on that.

    http://www.telerik.com/community/forums/aspnet/grid.aspx

    If you'd like to use GridView instead (because that's Microsoft control). I'd like to recommand you this:

    http://geekswithblogs.net/AzamSharp/archive/2005/12/21/63843.aspx

    Thursday, December 27, 2012 8:29 PM
  • User-1324178819 posted

    I use standart GridView to export to excel but the same thing happens.

    HTML code is separated into multiple cells :(

    protected void ExceleAktarLinkButton_Click(object sender, EventArgs e)
       {
           Response.Clear();
           Response.AddHeader("content-disposition", "attachment;filename=testExport.xls");
           Response.Charset = "";
           Response.Cache.SetCacheability(HttpCacheability.NoCache);
           Response.ContentType = "application/vnd.xls";
     
           System.IO.StringWriter stringWrite = new System.IO.StringWriter();
           HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
     
           form1.Controls.Clear();
           form1.Controls.Add(GridView1);
           form1.RenderControl(htmlWrite);
           Response.Write(stringWrite.ToString());
           Response.End();
       }
     
       //HTML Codes into Visual HTML
       protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
       {
           if (e.Row.RowType == DataControlRowType.DataRow)
           {
               for (int j = 0; j < e.Row.Cells.Count; j++)
               {
                   string encoded = e.Row.Cells[j].Text;
                   e.Row.Cells[j].Text = Context.Server.HtmlDecode(encoded);
               }
     
           }
       }
    
    
    

    Screenshot(below) when exported from standart GridView.

    1 cell in my GridView is separated into multiple rows :(

    Friday, December 28, 2012 3:24 AM
  • User3866881 posted

    Hi,

    To be very honest, it's not an easy task to export a GridView with Html formation.

    Maybe you can try to use this tool:

    http://highoncoding.com/Articles/202_GridView_Export_to_Excel_Button_Control.aspx

    Friday, December 28, 2012 3:41 AM