Ver Mensaje Individual
  #1 (permalink)  
Antiguo 14/03/2007, 02:08
iruki
 
Fecha de Ingreso: noviembre-2006
Mensajes: 48
Antigüedad: 17 años, 6 meses
Puntos: 0
consulta sql exportada a excel pero abre como archivo word.

hola!!
tengo una ultima duda para mi exportación de un gridview a excel.
tengo este codigo:

string style = @"<style> body {font-family:Verdana;font-size:10px;text-align:center;width:500px;} </style> ";
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=Recepciones.xls");
Response.Charset = "";
Response.ContentType = "application/excel";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
GridView g = new GridView();
g.DataSource = r.CargarDatos();
g.DataBind();
g.CellPadding = 1;
g.CellSpacing = 1;
............
........
.........


y la tabla aparece correctamente, es un archivo excel pero cuando lo abres es en html. Luego si haces al archivo abrir con "excel for windows" la tabla se carga correctamente, con los datos puestos en su correspondiente celda.

yo quiero que no haya que hacer lo de abrir con... y directamente ponga la tabla en excel.
Hay que añadir algo al código?se puede hacer?