我试图从数据库向excel文件写入数据但我在阿拉伯语中出现了问题:
看起来像是:السبت
我试过这段代码:
Application.Lock();
SqlConnection con = Connection.Open();
SqlCommand com = new SqlCommand("SELECT u.* FROM sarcshiftuser AS u WHERE (table_id = (SELECT TOP (1) table_id FROM sarcshifttable ORDER BY table_id DESC)) ",con);
SqlDataAdapter da = new SqlDataAdapter(com);
DataTable usertable = new DataTable();
da.Fill(usertable);
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
string attachment = "attachment; filename=Employee.xls";
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.Charset = "UTF-8";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
HttpContext.Current.Response.AddHeader("content-disposition", attachment );
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
Response.Write("السبت"); // in this row I tried to write saturday word in arabic but its appear :`السبت`
Response.End();
Application.UnLock();
任何帮助? 另一个问题是否有可能: 如何合并单元格并将c#代码背后的单元格背景着色?
答案 0 :(得分:0)
HttpContext.Current.Response.Charset =" UTF-8&#34 ;; HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;