导出阿拉伯语消息以在 ASP.NET 网站上表现出色

本文关键字:网站 NET ASP 阿拉伯语 消息 | 更新日期: 2023-09-27 18:30:48

我有一个网站,它用阿拉伯语存储了一些消息。当我尝试将其导出为 csv 或 excel 时,它显示为 ? .下面是我用来导出它的代码

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();
}

如何解决这个问题。提前致谢

导出阿拉伯语消息以在 ASP.NET 网站上表现出色

将 ContentEncoding 更改为 windows-1256 或 utf-8。此外,最好使用更好的库来创建 excel 文件,例如 http://epplus.codeplex.com/