Ver Mensaje Individual
  #1 (permalink)  
Antiguo 01/09/2010, 17:56
Avatar de OlaIsa
OlaIsa
 
Fecha de Ingreso: diciembre-2005
Mensajes: 105
Antigüedad: 18 años, 5 meses
Puntos: 0
Exportar GridView a Excel, pero necesito que aparezca una imagen

Buenas tardes chicos, espero puedan ayudarme...

Tengo un GridView que necesito exportar a Excel...ya lo hace (jijiji lo encontre en Internet), pero ahora me pidieron que en el excel aparezca un logo, y ya intente con la etiqueta image y object pero no sale...sabe alguien como se debe hacer esto?

Abajo el codigo que ejecuto para enviar a Excel con el html que ya le agregue.

Código:
private void Exportar(GridView gv)
        {
            try
            {
                StringBuilder sb = new StringBuilder();
                StringWriter sw = new StringWriter(sb);
                HtmlTextWriter htw = new HtmlTextWriter(sw);

                Page page = new Page();
                HtmlForm form = new HtmlForm();
                String inicio;

                Style stylePrueba = new Style();
                stylePrueba.Width = Unit.Pixel(200);
                inicio = "<div> " +
                          "<table border=0 cellpadding=0 cellspacing=0 width=480>" +
			                    "<tr height=17 >" +
                                    "<td height=17 > <img alt='Logo_FR' src='../Images/LogoFR2.gif'/></td>" +
			                    	"<td height=17 colspan=2 ></td>" +
                                    "<td colspan=4 align=center><h1>Reporte Regulatorio</h1></td>" +
			                    "</tr>" +
			                    "<tr height=17>" +
				                    "<td height=17 colspan=2 ></td>" +
			                    "</tr>" +
			                    "<tr height=17 >" +
				                    "<td height=17 colspan=2 ></td>" +
				                    "<td>Regional:</td>" +
			                    "</tr>" +
			                    "<tr height=17 >" +
				                    "<td height=17 colspan=2 ></td>" +
				                    "<td>Agencia:</td>" +
			                    "</tr>" +
		                    "</table>" + 
                            "</div>";
                sb.Append(inicio);
                // 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();
                inicio = "hola";
                page.Controls.Add(form);
                form.Controls.Add(gv);
                page.RenderControl(htw);
                
                Response.Clear();
                Response.Buffer = true;
                Response.ContentType = "application/vnd.ms-excel";
                Response.AddHeader("Content-Disposition", "attachment;filename=Reporte Regulatorio del " + txtFechaInicial.Text + " al " + txtFechaFinal.Text + ".xls");
                Response.Charset = "UTF-8";
                Response.ContentEncoding = Encoding.Default;
                Response.Write(sb.ToString());
                Response.End();
            }
            catch
            {
                throw;
            }
        }
__________________
Se feliz!!!!!