Home Page
Articoli
Tips & Tricks
News
Forum
Archivio Forum
Blogs
Sondaggi
Rss
Video
Utenti
Chi Siamo
Contattaci
Username:
Password:
Login
Registrati ora!
Recupera Password
Home Page
Stanze Forum
ASP.NET 2.0 / 3.5 / 4.0
Dataset/Gridview to xls, problema con lettere accentate
giovedì 16 luglio 2009 - 09.10
Elenco Threads
Stanze Forum
Aggiungi ai Preferiti
Cerca nel forum
a.malisani
Profilo
| Newbie
33
messaggi | Data Invio:
gio 16 lug 2009 - 09:10
Salve, ho un problema con l'esprtazione da datset/gridview in excel... Nel file generato tutte le lettere accentate "ò à ù è ì" diventato altri simboli tipo ù per la ù...
cosa posso fare????
System.Web.UI.WebControls.DataGrid grid = new System.Web.UI.WebControls.DataGrid();
grid.HeaderStyle.Font.Bold = true;
grid.DataSource = data;
grid.DataBind();
string attachment = "attachment; filename=Export.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
grid.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
Alessandro
LuxSkyWalker
Profilo
| Junior Member
68
messaggi | Data Invio:
gio 16 lug 2009 - 09:28
Ciao...ti riferisci ai caratteri html giusto?
Se sì, anche io avevo avuto in passato un problema simile...realizzati un metodo che va a fare un replace dei caratteri html...
Ok?Tutto chiaro?
LuxSkyWalker
Junior Developer .NET
a.malisani
Profilo
| Newbie
33
messaggi | Data Invio:
gio 16 lug 2009 - 10:04
Esempio menù diventa menù.... qundi prima di generare l'xls dovrei trasformare menù in menu' ?
LuxSkyWalker
Profilo
| Junior Member
68
messaggi | Data Invio:
gio 16 lug 2009 - 10:34
private string PulisciDaHTML(string testo)
{
//Sostituisce eventuali caratteri html con l'opportuna codifica.
return HttpUtility.HtmlDecode(testo);
}
Io uso un metodo cosi...gli passi il campo da esportare e lui lo pulisce automaticamente...
Prova e fammi sapere!!!!
LuxSkyWalker
Junior Developer .NET
a.malisani
Profilo
| Newbie
33
messaggi | Data Invio:
gio 16 lug 2009 - 11:00
purtroppo non funziona, ho risolto aggiungiendo:
"Response.ContentEncoding = System.Text.Encoding.GetEncoding("latin9");//per evitare errori negli acccenti"
string attachment = "attachment; filename=Contacts.xls";
---> Response.ContentEncoding = System.Text.Encoding.GetEncoding("latin9");//per evitare errori negli acccenti
Response.ClearContent();
grazie del supporto!
Alessandro
Developer .NET
LuxSkyWalker
Profilo
| Junior Member
68
messaggi | Data Invio:
gio 16 lug 2009 - 11:18
Non funziona perchè?
Se il problema è lo stesso, dovrebbe risolvertelo...
LuxSkyWalker
Junior Developer .NET
a.malisani
Profilo
| Newbie
33
messaggi | Data Invio:
gio 16 lug 2009 - 15:15
non saprei perche non ha funzionato..pero voglio capire... mi sembrava corretto,
appena posso provo a vediamo perche....
Alessandro
Developer .NET
LuxSkyWalker
Profilo
| Junior Member
68
messaggi | Data Invio:
gio 16 lug 2009 - 15:19
Certo che è corretto...è in ambiente di produzione nella mia azienda!!!
Magari non l'hai chiamato nel modo corretto...non saprei...se hai cmq bisogno, non hai che da scrivere!
ciau
LuxSkyWalker
Junior Developer .NET
a.malisani
Profilo
| Newbie
33
messaggi | Data Invio:
ven 17 lug 2009 - 09:05
esatto non l'ho chiamo nel modo corretto!
Grazie!
Alessandro
Developer .NET
LuxSkyWalker
Profilo
| Junior Member
68
messaggi | Data Invio:
ven 17 lug 2009 - 10:40
LuxSkyWalker
Junior Developer .NET
Torna su
Stanze Forum
Elenco Threads
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?
Dopo esserti registrato potrai chiedere
aiuto sul nostro
Forum
oppure aiutare gli altri
Consulta le
Stanze
disponibili.
Registrati ora !