P
Paul D. Fox
When I run my Export to Excel, the Spreadheet is empty. Anyone know what may cause this? Here is my code:
Response.Clear()
Response.Charset = ""
Response.ContentType = "application/vnd.ms-excel"
Response.AppendHeader("Content-Disposition", "attachment;filename=" & strFileName & ".xls")
Dim stringWrite As New System.IO.StringWriter
Dim htmlWrite As New System.Web.UI.HtmlTextWriter(stringWrite)
Dim dg As New DataGrid
'Copy data from existing Datagrid to the new Datagrid
dg = dgExport
dg.AllowPaging = False
dg.AllowCustomPaging = False
dg.AllowSorting = False
dg.EnableViewState = False
'Lets make it a generic looking spreadsheet
dg.HeaderStyle.BackColor = Color.LightGray
dg.AlternatingItemStyle.BackColor = Color.White
dg.FooterStyle.BackColor = Color.LightGray
dg.PagerStyle.BackColor = Color.Gainsboro
dg.HeaderStyle.Font.Bold = True
dg.DataBind()
dg.RenderControl(htmlWrite)
Response.Write(stringWrite.ToString)
Response.End()
Paul
Response.Clear()
Response.Charset = ""
Response.ContentType = "application/vnd.ms-excel"
Response.AppendHeader("Content-Disposition", "attachment;filename=" & strFileName & ".xls")
Dim stringWrite As New System.IO.StringWriter
Dim htmlWrite As New System.Web.UI.HtmlTextWriter(stringWrite)
Dim dg As New DataGrid
'Copy data from existing Datagrid to the new Datagrid
dg = dgExport
dg.AllowPaging = False
dg.AllowCustomPaging = False
dg.AllowSorting = False
dg.EnableViewState = False
'Lets make it a generic looking spreadsheet
dg.HeaderStyle.BackColor = Color.LightGray
dg.AlternatingItemStyle.BackColor = Color.White
dg.FooterStyle.BackColor = Color.LightGray
dg.PagerStyle.BackColor = Color.Gainsboro
dg.HeaderStyle.Font.Bold = True
dg.DataBind()
dg.RenderControl(htmlWrite)
Response.Write(stringWrite.ToString)
Response.End()
Paul