老問題,網頁導出Excel問題.

dragonlus 2007-01-22 05:31:56
Response.Clear();
Response.Charset = Request.ContentEncoding.EncodingName;//設定字符集
Response.BufferOutput = true;
Response.ContentType = "application/vnd.ms-excel";//設定導出格式
System.IO.StringWriter oSW = new System.IO.StringWriter();
HtmlTextWriter oHW = new HtmlTextWriter(oSW);
oSW.Write(value);//將數據寫入.
Response.Write(oSW.ToString());
Response.Flush();
Response.Close();

上面是一段導出Excel的代碼.
Response.Charset = Request.ContentEncoding.EncodingName;//設定字符集
這句中,不管設定什麼樣的字符集,所用的字符集都是默認的Unicode.
不管設定什麼樣的字符集,總是會導出亂碼,由什麼方法解決.
...全文
248 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
dragonlus 2007-01-23
  • 打赏
  • 举报
回复
看來還是字符集的問題.繁體的就是麻煩,差不多可以解決了.
孟子E章 2007-01-22
  • 打赏
  • 举报
回复
http://dotnet.aspx.cc/article/700bd3fa-a17f-41dc-b258-0dc572625700/read.aspx
孟子E章 2007-01-22
  • 打赏
  • 举报
回复
Response.ContentEncoding = System.Text.Encoding.UTF7;
hertcloud 2007-01-22
  • 打赏
  • 举报
回复
将页面上的
类似<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
代码去掉看
jinglong6511 2007-01-22
  • 打赏
  • 举报
回复
看看

110,529

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧