468,294 Members | 1,837 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,294 developers. It's quick & easy.

Export Grid View To Excel without template field

I have Grid view which contains template fields like drop down list and text box

When i export grid view to excel 2010

The excel to which i exported grid view also contains drop down and text boxes which are in grid view.
Which i do not want.I just want value selected in drop down to be exported to excel sheet not entire drop down

My code is below for exporting
Expand|Select|Wrap|Line Numbers
  1.         Try
  2.  
  3.             'EXPORTING REPORT TO APPROVER GRID EXCEL.
  4.             Response.ClearContent()
  5.             Response.Buffer = True
  6.             Response.AddHeader("content-disposition", String.Format("attachment; filename={0}", "Salary_Revision_Approver.xls"))
  7.             Response.ContentType = "application/ms-excel"
  8.             Dim sw As New StringWriter()
  9.             Dim htw As New HtmlTextWriter(sw)
  10.             gvsrapprogrid.AllowPaging = False
  11.             gvsrapprogrid.Columns(13).Visible = False
  12.  
  13.             gvsrapprogrid.HeaderRow.Style.Add("background-color", "#FFFFFF")
  14.             For i As Integer = 0 To gvsrapprogrid.HeaderRow.Cells.Count - 1
  15.                 gvsrapprogrid.HeaderRow.Cells(i).Style.Add("background-color", "#df5015")
  16.             Next
  17.             gvsrapprogrid.RenderControl(htw)
  18.             Response.Write(sw.ToString())
  19.  
  20.         Catch ex As Exception
  21.  
  22.             Page.ClientScript.RegisterStartupScript(Page.GetType(), "alertmesg", "<script language=javascript> alert('DATA NOT AVAILABLE TO BE VIEWED');</script>")
  23.  
  24.         End Try
  25.  
  26.         Response.End()
  27.  
Feb 12 '15 #1
2 2953
Frinavale
9,735 Expert Mod 8TB
I've never done what you are doing but have you tried exporting the source of the GridView instead of the GridView itself.

Is the source a DataTable?
It should contain all of the information the user provided while editing.

-Frinny
Feb 19 '15 #2
I doubt that you can do this with a gridview.

Try using a Data table instead of a GridView. It can also be used for such purposes in "FastReport", there it is done very simply.
Apr 8 '20 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Rob | last post: by
9 posts views Thread by | last post: by
reply views Thread by CSharpguy | last post: by
2 posts views Thread by bbawa1 | last post: by
1 post views Thread by =?Utf-8?B?Ym9iYnk=?= | last post: by
1 post views Thread by John | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by Teichintx | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.