views:

191

answers:

1

Hi All, I have a web application where I am using asp.net tree view control to show data. No I want that this tree view structure has to exported to excel. Following is the code which do this for me.

private void ExportSiteStructure()
        { 
            Response.Clear();
            Response.Buffer = true;
            Response.ContentType = "application/vnd.ms-excel";
            Response.Charset = "";
            this.EnableViewState = false;
            System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
            TreeVWSite.RenderControl(oHtmlTextWriter);
            if (TreeVWGroups.Nodes.Count > 0)
            {
                TreeVWGroups.RenderControl(oHtmlTextWriter);   
            }
            Response.Write(oStringWriter.ToString());
            Response.End();
        }

It works perfect but the report what it gives me contains all parent and child node of tree view get palced in excell cell as well as icons and checkboxes which I have use.

What I want is to have only Text in excel cell that represent node of tree view and not those icons and checkboxes associated with them.

Can any one help me out to solve this issue..

Thanks in advance

Sachin katkar.

A: 

Hey,

It renders out whatever's in the response, so I think you can set the tree to disable the icons an checkboxes before you do the rendering... Try that, if not, you may need to copy the data to an alternative control to achieve it, and render that control out.

Brian