Click here to Skip to main content
15,885,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
it shows garbage value for data which is not in English and is in different language

I have tried following code,

C#
HttpContext.Current.Response.Clear();
           HttpContext.Current.Response.ClearContent();
           HttpContext.Current.Response.ClearHeaders();
           HttpContext.Current.Response.Buffer = true;
           HttpContext.Current.Response.ContentType = "application/vnd.xlsx";
           HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + SheetName +  DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss-fff")+".xls");
           HttpContext.Current.Response.Charset = "utf-8";
           HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1250");
           To = Convert.ToDateTime(To).AddDays(-1).ToString("yyyy-MM-dd");
           string html = getHTMLtableFromDataTable(dt, SheetName,From, To);

           HttpContext.Current.Response.Write(style);
           HttpContext.Current.Response.Output.Write(html);
               HttpContext.Current.Response.Flush();
               HttpContext.Current.Response.End();
Posted
Updated 6-Mar-16 20:08pm
v3
Comments
Mycroft Holmes 7-Mar-16 2:10am    
I suspect it will have something to do with utf-8 which does not support unicode characters or possibly the content encoding.
Sinisa Hajnal 7-Mar-16 3:11am    
Youre using eastern europe encoding which provides characters such as č, ž, š etc...not sure which language do you need...also, you're encoding in utf-8, try unicode. Or research what encoding works for your particular language.
aparnaChandras 8-Mar-16 0:02am    
I want to display data in both English & Hindi
Harshad Kathiriya 7-Mar-16 7:45am    
did you tried with utf-16?
aparnaChandras 8-Mar-16 0:01am    
yes i have tried utf-16 also but it does not work

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900