When I export a datagrid that contains currency values (with the pound sign, £) to Excel I get £0.00. I have seen this before when transforming XSL with UTF-8 encoding so I tried iso-8859-1 but it made no difference. Does anyone know how to solve this please? Here is a snippet of my code
Which outputs..
Department Nov
Finance £0.00
Internal Systems £0.00
Legal £0.00
Total £0.00
Thanks
Matt
Code:
Response.Clear();
Response.Buffer= true;
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "iso-8859-1";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
this.EnableViewState = false;
Response.Write("\r\n");
Response.Write("<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">");
Response.Write("\r\n");
Response.Write("<style> .mystyle1 "+"\r\n"+"{mso-number-format:\""+@"\@"+"\""+";} "+"\r\n"+"</style>");
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter( oStringWriter );
this.ClearControls(MySQLDataGrid);
MySQLDataGrid.RenderControl( oHtmlTextWriter );
//Response.AppendHeader("content-disposition","attachment;filename=x.xls");
Response.Write(oStringWriter.ToString());
Response.End();
Which outputs..
Department Nov
Finance £0.00
Internal Systems £0.00
Legal £0.00
Total £0.00
Thanks
Matt