asp.net - Remove Image in excel header after exporting the gidview -


Please help me on how to extract an image in my Excel header I use the Excel export command as the source data of gridview Using

My code is generating here

  Response.AddHeader ("content-effect", "attachment; file name =" & strfilename & amp; ".xls") Response.Clear () Response.Charset = "" Response.ContentType = "application / vnd.xls" dim sw System.IO.StringWriter = New System.IO.StringWriter () Dim as HTW In System.Web.UI.HtmlTextWriter = New System.Web.UI.HtmlTextWriter (SW) grvData.AllowPaging = false grvDa Ta.AllowSorting = False PopulateGrid () grvData.RenderControl (HTW) Response.Write (sw.ToString) Response.End ()   

Everything was set-except that my title There was a blank header name due to the image, which was now shown - the image came from the gridview (I am using the arrow for ARC and desc) - sorry, I can not post any image here now! /p>

Give it a shot to the ClearControls method It turns any control from the grid before exporting Should give:

  protected void btnExport_Click (object sender, EventArgs e) {Response.Clear (); reaction. Buffer = true; Response.ContentType = "app / vnd.ms-excel"; Response. Charset = ""; System.IO.StringWriter oStringWriter = New System.IO.StringWriter (); System.Web.UI.HtmlTextWriter oHtmlTextWriter = New System. Web.UI.HtmlTextWriter (oStringWriter); This.ClearControls (DataGrid1); DataGrid1.RenderControl (oHtmlTextWriter); DataGrid1.GridLines = Gridlines Both; DataGrid1.Style.Clear (); Response.Write (oStringWriter.ToString ()); Response.End (); } Private Zero ClearControls {for (int i = control.Controls.Count - 1; i> = 0; i--) {ClearControls (control.Controls [i]); } If {if (control.GetType () getProperty ("SelectedItem") = Null.!) {LiteralControl is literally = New LiteralControl () ((Control TableCell)!); Control.Parent.Controls.Add (literal); Try {literal.Text = (string) control.GetType (). GetProperty ("SelectedItem"). GetValue (Control, Empty); } Hold {nothing} at the end {control.Parent.Controls.Remove (control); }} And {if (control.GetType (.) GetProperty ("Text")! = Null) {literalControl literal = New LiteralControl (); Control.Parent.Controls.Add (literal); Literal.Text = (string) control.GetType (). GetProperty ("Text"). GetValue (Control, Empty); Control.Parent.Controls.Remove (control); }}} Return; }    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -