I want to export the data from a DaraGrid into an Excel file. Having these data in a french language
Here you are my method:
public static void ExportGridView( DataGrid dataGrid, string fileName)
{
HttpResponse m_Response = HttpContext.Current.Response;
m_Response.Clear();
m_Response.AddHeader("content-disposition",
string.Format("attachment;filename={0}", fileName));
m_Response.Charset = "";
m_Response.ContentType = "application/octet-stream"; //"application/vnd.xls";
m_Response.ContentEncoding = Encoding.UTF32;
StringWriter stringWrite = new StringWriter();
HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
dataGrid.RenderControl(htmlWrite);
m_Response.Write(stringWrite.ToString());
m_Response.End();
}
Otherwise the output isn’t in a the good French format
Ex )
Engagé => engagé
Société => Société
Try using
ISO-8859-1:Another alternative and probably better is to generate an entire HTML page and specify the UTF8 encoding which IMHO is better: