Tag: unicodestring

从GridView导出到Excel不正确地显示波斯语

绑定GridView的SqlDataSource,我写下面的代码从GridView导出到Excel: System.IO.StringWriter sw = new System.IO.StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.ContentType = "application/vnd.ms-excel"; Response.AddHeader("Content-Disposition", "attachment;filename=" + FileName); gvReportPrint.GridLines = GridLines.Both; gvReportPrint.Font.Name = "'BYekan'"; foreach (GridViewRow row in gvReportPrint.Rows) { row.Cells[2].Attributes.Add("class", "textmode"); } string style = @"<style> .textmode { mso-number-format:\@; } </style>"; gvReportPrint.HeaderStyle.Font.Bold = true; Response.Write(style); gvReportPrint.RenderControl(hw); Response.Output.Write(sw.ToString()); Response.End(); 在从GridView导出到Excel的过程中,unicode字符不能正确显示,它们显示如下: – >单击此链接显示问题< –