Para exportar a Ecxel SIN USAR LIBRERIAS la info de un Data Grid yo uso esto, espero te sirva: En C# Código HTML:
protected void btExportar_Click(object sender, EventArgs e)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
System.IO.StringWriter sw = new System.IO.StringWriter(sb);
System.Web.UI.HtmlTextWriter htw = new System.Web.UI.HtmlTextWriter(sw);
Page page = new Page();
HtmlForm form = new HtmlForm();
GridView1.EnableViewState = false;
// Deshabilitar la validación de eventos, sólo asp.net 2
page.EnableEventValidation = false;
// Realiza las inicializaciones de la instancia de la clase Page que requieran los diseñadores RAD.
page.DesignerInitialize();
page.Controls.Add(form);
form.Controls.Add(GridView1);
page.RenderControl(htw);
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", "attachment;filename=DATA.xls");
Response.Charset = "UTF-8";
// Response.ContentEncoding = Encoding.Default;
Response.Write(sb.ToString());
Response.End();
}
En VB
Imports System.IO
Dim sb As StringBuilder = New StringBuilder()
Dim sw As StringWriter = New StringWriter(sb)
Dim htw As HtmlTextWriter = New HtmlTextWriter(sw)
Dim pagina As Page = New Page
Dim form = New HtmlForm
grilla.EnableViewState = False
pagina.EnableEventValidation = False
pagina.DesignerInitialize()
pagina.Controls.Add(form)
form.Controls.Add(grilla)
pagina.RenderControl(htw)
Response.Clear()
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("Content-Disposition", "attachment;filename=data.xls")
Response.Charset = "UTF-8"
Response.ContentEncoding = Encoding.Default
Response.Write(sb.ToString())
Response.End()
Saludos!!