C sharp - pregunta sencilla

 
Vista:

pregunta sencilla

Publicado por carlos (1 intervención) el 18/04/2008 17:14:36
Hola estoy tratando de exportar de mi aplicación C# un datagrid a un archivo excel
abre el archivo bien con las columnas y filas pero también se lleva al archivo excel los botones de mi página web :S

Cómo hago para que solo exporte lo que está en el gridview¿¿??

este es el código que tengo
---------------------------
Response.Clear();

Response.AddHeader("content-disposition", "attachment; filename=FileName.xls");

Response.Charset = "";

// If you want the option to open the Excel file without saving than

// comment out the line below

Response.Cache.SetCacheability(HttpCacheability.NoCache);

Response.ContentType = "application/vnd.xls";

System.IO.StringWriter stringWrite = new System.IO.StringWriter();

System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);

GridView1.RenderControl(htmlWrite);

Response.Write(stringWrite.ToString());

Response.End();
-----------

gracias de antemano!!!!!!!
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder