Google+ Tools
Make Google+ profile picture
Make Google plus banners for profile
Create and share your Google Plus profile banners.

Profile image for mrk studios Rajeev Jain on July 28, 2009
Download Grid Data in Excel
Language
VB.NET
Tags

Download Grid Data in Excel


Private Function DataSetToExcel(ByVal dv As DataView, ByVal response As HttpResponse) As Boolean
        response.Clear()
        response.Charset = ""
        response.Buffer = True

        'response.ContentType = "application/vnd.ms-excel"

        response.ContentType = "application/ms-excel"
        response.AddHeader("content-disposition", "inline; filename=PromoCodeHistory.xls")
        Dim stringWrite As New System.IO.StringWriter
        Dim htmlWrite As New System.Web.UI.HtmlTextWriter(stringWrite)

        Dim pnl As New Panel
        Dim dg As New DataGrid
        Dim lbAmount As New Label
        Dim lbDiscount As New Label
        Dim lbSpace As New Label
        lbSpace.Text = "   "
        lbAmount.Text = tdTotalAmount.InnerText
        lbDiscount.Text = tdTotalDiscount.InnerText
        dg.DataSource = dv
        dg.DataBind()
        pnl.Controls.Add(dg)
        pnl.Controls.Add(lbAmount)
        pnl.Controls.Add(lbSpace)

        pnl.Controls.Add(lbDiscount)

        pnl.RenderControl(htmlWrite)

        
        response.Write(stringWrite.ToString())
        response.End()

        Return True
    End Function

Comments

blog comments powered by Disqus