Ask a Question related to ASP.NET Data Grid Control, Design and Development.
-
Paul D. Fox #1
Export to Excel shows an empty sheet
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
Paul D. Fox Guest
-
How to get the name of an Excel sheet?
It's a COM call via CFObject but be warned - if there are External Links in the spreadsheet or VBA code, you could have issues. I'll post some code... -
Excel sheet creation from ASP
Hi. Simple ASP creates Excel file on C drive: Dim xls Set xls = CreateObject( "Excel.Application") xls.Workbooks.Add... -
Export IPTC-Headers into Excel-Sheet
I would like to Export IPTC-Header-information to an Excel-Sheet from about 300 Photoshop-jpg-Files. Any idea how? Rike -
Excel Sheet Export
Hi All, I have an Excel sheet which I recieve every week. Its not too much data and the present process is to manually load that data into a SQL... -
Export to Excel sheet
You may refer to this KB article: http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q288130 Luke (This posting is provided "AS IS",... -
Paul D. Fox #2
Re: Export to Excel shows an empty sheet
I seemed to have found the Issue. in my Page_Load event I have...
The Page_Load event has the following:
If Not Page.IsPostBack Then
dgrdLCFDynamicReport.SelectedIndex = 0
If dgrdLCFDynamicReport.Attributes("SortExpression") Is Nothing Then
dgrdLCFDynamicReport.Attributes("SortExpression") = "Create_Date" 'Default Sort
dgrdLCFDynamicReport.Attributes("SortDirection") = "ASC"
End If
Bind_dgrdLCFDynamicReport()
End If
This prevents the ability to Export the datagrid to Excel. By Removing the If/End If statement, the Datagrid can be properly exported. Not sure if this is actually an ASP.NET error or what...
Paul
"Paul D. Fox" <pdfox99@rcn.com> wrote in message news:uNgCxlpPFHA.2824@TK2MSFTNGP10.phx.gbl...
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
Paul D. Fox Guest



Reply With Quote

