Hello All
I use following code to export a datagrid to excel:
//---------------------------------------------------------------------------------------------------------------------
GridView2.Visible = true;
Response.Clear();
Response.AddHeader("content-disposition",
"attachment;filename=Export.xls");
Response.Charset = "";
Response.ContentType = "application/vnd.ms-excel";
System.IO.StringWriter stringWrite = new
System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new
HtmlTextWriter(stringWrite);
EnableViewState = false;
GridView2.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
GridView2.Visible = false;
//---------------------------------------------------------------------------------------------------------------------
GridView2 is a hidden Gridview on a page that contains all the fields
i want to export.
This Code works fine (except that Excel 2007 gives me an error
message, but i ignore that).
The Fields that are exported contain Text in English, German, Italian
and French.
Most of it looks perfect and I'm pretty happy with what it does, BUT
in a couple of texts
(Only French as far I can see) it looks like that:
Pour le gaz, l’Association suisse de l’industrie du gaz fournit à
l’Office fédéral de
instead of
Pour le gaz, l’Association suisse de l’industrie du gaz fournit à
l’Office fédéral de
so as far as I can tell it's whenever an apostrophe follows an l, but
I found other fields where it looks they way it should:
Excelsheet: Taxes pour l'incinération des déchets
Website: Taxes pour l'incinération des déchets
Does anyone know what the problem could be?
I was thinking of some charset issues, but it's still strange that it
doesn't happen all the time.
Thanks in advance for any input you can give
Carlo