Foros del Web » Programación para mayores de 30 ;) » Bases de Datos General » SQL Server »

Issues saving HTML with Content-Disposition

Estas en el tema de Issues saving HTML with Content-Disposition en el foro de SQL Server en Foros del Web. Hi guys, I have some issues, saving a HTML content into Excel format. I just populate a StringBuilder and then display it into a WebControl ...
  #1 (permalink)  
Antiguo 02/08/2010, 14:38
 
Fecha de Ingreso: mayo-2010
Mensajes: 4
Antigüedad: 14 años
Puntos: 0
Issues saving HTML with Content-Disposition

Hi guys, I have some issues, saving a HTML content into Excel format. I just populate a StringBuilder and then display it into a WebControl Panel, juzt like this:
Código:
resultados.Controls.Add(new LiteralControl(sb.ToString()));
And then I set the ContentType and I add a header to download the content. This is the code:


Código:
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", "attachment; filename=Indicador.xls");
Response.ContentEncoding = Encoding.UTF8;
Response.Charset = "";
Response.Write(sb.ToString());
The data that I get from the database, which I display into the StringBuilder. Sometimes the whole document get disturbed with strange characteres, like if it wasn´t UTF-8 text.

It's very strange and it happened to me a lot of times and I want to know once and for all what is happening.

This is one example of the text that causes the whole mess.


"La tasa está calculada a mitad del período. La etiqueta 1987 representa el período 1987-1992. La etiqueta 1992 representa el período 1992-1997. La etiqueta 1997 representa el período 1997-2002. La etiqueta 2004 representa el período 2004-2009."

As you can see, it's spanish and it may be because the accents.

If I only take till the second sentences, it doesn't happend, and you can realize that "está" and "período" have accent. Therefore it's not because the accent.

Afterwards, I take till the third sentence and everything get into a mess... and I can't find what is happening. There must be some special characteres, that I cannot see? Also de fourth sentence make some noise on the document.

¿What is going on with the encoding process?

I will really appreciate if you could advise me some how.

Thank you in advance.

Raul Bolaños.

Etiquetas: html
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 06:42.