N
Ned Balzer
I have a puzzling problem. I am using some code I found in another
thread here to output the results of a gridview to excel. Here is the
subroutine:
Sub SendToExcel(ByVal Source As Object, ByVal E As EventArgs)
Dim gv As GridView =
Ctype(ColRep1Form.FindControl("xlsRep1GridView"),
GridView)
If gv.Rows.Count.ToString + 1 < 65536 Then
gv.AllowPaging = False
gv.AllowSorting = False
Dim tw As New System.IO.StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
Response.Clear()
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("content-disposition",
"attachment;filename=dept1.xls")
Response.Charset = ""
EnableViewState = False
gv.visible= true
gv.RenderControl(hw)
Response.Write(tw.ToString())
Response.End()
gv.DataBind()
End If
End Sub
This code works in firefox, or in IE when saving (not opening) the file
from the open/save dialogue. It doesn't work at all in IE when the
website is using https.(but it does work when using Firefox).
I would be grateful for any advice or explanation.
Thanks.
-- Ned
thread here to output the results of a gridview to excel. Here is the
subroutine:
Sub SendToExcel(ByVal Source As Object, ByVal E As EventArgs)
Dim gv As GridView =
Ctype(ColRep1Form.FindControl("xlsRep1GridView"),
GridView)
If gv.Rows.Count.ToString + 1 < 65536 Then
gv.AllowPaging = False
gv.AllowSorting = False
Dim tw As New System.IO.StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
Response.Clear()
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("content-disposition",
"attachment;filename=dept1.xls")
Response.Charset = ""
EnableViewState = False
gv.visible= true
gv.RenderControl(hw)
Response.Write(tw.ToString())
Response.End()
gv.DataBind()
End If
End Sub
This code works in firefox, or in IE when saving (not opening) the file
from the open/save dialogue. It doesn't work at all in IE when the
website is using https.(but it does work when using Firefox).
I would be grateful for any advice or explanation.
Thanks.
-- Ned