Dim dsExport As New DataSet() Dim tw As New System.IO.StringWriter() Dim hw As New System.Web.UI.HtmlTextWriter(tw) Dim dgGrid As New DataGrid() dgGrid.DataSource = dv'where dv is the shared dataview containing the data from database dgGrid.HeaderStyle.Font.Bold = True dgGrid.DataBind() dgGrid.RenderControl(hw) ' Write the HTML back to the browser. Response.ContentType = "application/vnd.ms-excel" Me.EnableViewState = False Response.Write(tw.ToString()) Response.End()