hi...
I am Exporting chinese data to Microsoft Excel....while exporting sometimes chinese chars appears as special chars in the excel sheet and sometimes not.I have tried lot many thing for making it consistent.
I have used following code.
DataTable oDt;
Response.Clear();
Response.Buffer=true;
Response.AddHeader("content-disposition", "attachment;filename=file.xls");
//Response.Charset = "";
Response.ContentEncoding = System.Text.Encoding.UTF7;
Response.Cache.SetCacheability(HttpCacheability.Private);
Response.ContentType = "application/vnd.ms-excel";
//Response.ContentEncoding = Encoding.GetEncoding("gb2312");System.IO.StringWriter stringWrite =
new System.IO.StringWriter();System.Web.UI.HtmlTextWriter htmlWrite =
new HtmlTextWriter(stringWrite);StringBuilder sbHTML =
new StringBuilder();//Creating string with HTML in it for Export
ResourceManager rm; //For getting localized data
rm =
new ResourceManager("MyProj.Resources.myFile",this.GetType().BaseType.Assembly);sbHTML.Append("
| " + rm.GetString("lblName") + " | ");" + rm.GetString("lblSurname") + " | ");
| " + dr["Name"] + " | ");" + dr["Surname"] + " | ");
Response.Write(sbHTML.ToString());
Response.End();
Please anybody...suggest a consistent solution for this problem.
Replies
Know the answer? Post it — somebody with the same question will find it here.