Foro de elhacker.net

Programación => .NET (C#, VB.NET, ASP) => Mensaje iniciado por: salvades en 26 Enero 2009, 14:50 pm



Título: Problema que no he podido solucionar
Publicado por: salvades en 26 Enero 2009, 14:50 pm
Buenas:

Tengo un website que me permite exportar a excel unos datos de una grilla anterior, en el ambiente de desarrollo que incorpora Visual Studio 2008 me funciona correctamente y estos datos efectivamente llevan al excel.

El problema de presenta cuando se sube la aplicacion al IIS version 5.1 SP3
la aplicacion se sube correctamente pero al momento de exportar a excel aparece el sgt error:

Error al recuperar un generador de clases COM para el componente con CLSID {00024500-0000-0000-C000-000000000046} debido al siguiente error: 80070005.

investige el error y llege a esta web que explican que el error es referente a un proceso de identidad


http://blog.crowe.co.nz/archive/2006/03/02/589.aspx


hize lo que sale en este articulo :

Configure DCOM

    * Go to the Start-Run menu item.
    * Type in "DCOMCNFG" and hit enter.
    * This should load the "Component Services" MMC (you can also load from Administrative Tools - Component Services"
    * Expand "Component Services"
    * Expand "Computers"
    * Expand "My Computer"
    * Select the "DCOM Config" item
    * Select the "Microsoft Excel Application" item


pero no me sale la opcion:

  * Select the "Microsoft Excel Application" item


alguna idea de como ayudarme ?



Título: Re: Problema que no he podido solucionar
Publicado por: salvades en 26 Enero 2009, 15:17 pm
Lo solucione escribiendo unas pequeñas lineas de codigo:

 StringBuilder sb = new StringBuilder();

       StringWriter sw = new StringWriter(sb);

       HtmlTextWriter htw = new HtmlTextWriter(sw);

       Page page = new Page();

       HtmlForm form = new HtmlForm();

       GridView1.EnableViewState = false;

       page.EnableEventValidation = false;

       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.ContentType = "text/plain";

       Response.AddHeader("Content-Disposition", "attachment;filename=data.xls");

       Response.Charset = "UTF-8";

       Response.ContentEncoding = Encoding.Default;

       Response.Write(sb.ToString());

       Response.End();



y funciono altiro

adjunto web del codigo fuente Saludos


http://geeks.ms/blogs/gperez/archive/2007/07/26/exportar-gridview-a-excel.aspx


 :rolleyes: :rolleyes: :rolleyes: :rolleyes: :rolleyes: :rolleyes: