Reputation: 29
I am having a website which stores some message in arabic .When i try to export it to a csv or excel , it comes as ? . Below is code which i use to export it
public void DownloadCSV(string csvData, string filename)
{
string strFileName = filename;
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=" + strFileName);
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("iso-8859-2");
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
HttpContext.Current.Response.Write(csvData);
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.End();
}
How can solve this problem . Thanks in advance
Upvotes: 1
Views: 1608
Reputation: 19156
Change the ContentEncoding to windows-1256 or utf-8. Also it's better to use a better library for creating excel files such as http://epplus.codeplex.com/
Upvotes: 2