Export Grid View To Excel without template field

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rahul2310
    New Member
    • Oct 2013
    • 62

    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
    Code:
            Try
    
                'EXPORTING REPORT TO APPROVER GRID EXCEL.
                Response.ClearContent()
                Response.Buffer = True
                Response.AddHeader("content-disposition", String.Format("attachment; filename={0}", "Salary_Revision_Approver.xls"))
                Response.ContentType = "application/ms-excel"
                Dim sw As New StringWriter()
                Dim htw As New HtmlTextWriter(sw)
                gvsrapprogrid.AllowPaging = False
                gvsrapprogrid.Columns(13).Visible = False
    
                gvsrapprogrid.HeaderRow.Style.Add("background-color", "#FFFFFF")
                For i As Integer = 0 To gvsrapprogrid.HeaderRow.Cells.Count - 1
                    gvsrapprogrid.HeaderRow.Cells(i).Style.Add("background-color", "#df5015")
                Next
                gvsrapprogrid.RenderControl(htw)
                Response.Write(sw.ToString())
    
            Catch ex As Exception
    
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "alertmesg", "<script language=javascript> alert('DATA NOT AVAILABLE TO BE VIEWED');</script>")
    
            End Try
    
            Response.End()
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    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

    Comment

    • Yamasiash
      New Member
      • Mar 2020
      • 4

      #3
      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.

      Comment

      Working...