Código vb:
Ver original
Dim sb As StringBuilder = New StringBuilder() Dim SW As System.IO.StringWriter = New System.IO.StringWriter(sb) Dim htw As HtmlTextWriter = New HtmlTextWriter(SW) Dim Page As Page = New Page() Dim form As HtmlForm = New HtmlForm() Me.Gv_asistencias.EnableViewState = False Page.EnableEventValidation = False Page.DesignerInitialize() Page.Controls.Add(form) form.Controls.Add(Me.Gv_asistencias) Page.RenderControl(htw) Response.Clear() Response.Buffer = True Response.ContentType = "application/vnd.ms-excel" Response.AddHeader("Content-Disposition", "attachment;filename=Reporte de asistencias" + Now.ToShortDateString + ".xls") Response.Charset = "UTF-8" Response.ContentEncoding = Encoding.Default Response.Write(sb.ToString()) Response.End()