asp.net生成execel文件打开时,薄名和title名都是乱码。解决方法
发布时间:2011-06-21 11:13:51 文章来源:www.iduyao.cn 采编人员:星星草
asp.net生成execel文件打开时,薄名和title名都是乱码。
asp.net生成execel文件打开时,薄名和title名都是乱码。
内容是正确的!
我的代码是这样的,
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.ContentType = "application/octet-stream ";
HttpContext.Current.Response.AddHeader( "Content-Disposition ", "attachment;filename= " + HttpUtility.UrlEncode(csvfilename + ".csv ", Encoding.UTF8));
HttpContext.Current.Response.BinaryWrite(Encoding.Default.GetBytes(csvcontent));
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.Close();
考了一段别人的asp的代码,就没有问题,
帮帮我,感谢大家了!!
------解决方案--------------------
把编码改成GB2312
------解决方案--------------------
HttpContext.Current.Response.BinaryWrite(Encoding.UTF-8.GetBytes(csvcontent));
另外,IE下载对话框点保存,不要打开,在临时文件夹下打开可能是乱码
------解决方案--------------------
报告楼主;你这是典型的编码问题
------解决方案--------------------
以前碰到过,当时没解决,最后换成,直接在服务器端生成Excel,然后再给用户下载,而不是用html方式输出。
------解决方案--------------------
aspx的编码跟
HttpUtility.UrlEncode(csvfilename + ".csv ", Encoding.UTF8));
HttpContext.Current.Response.BinaryWrite(Encoding.Default.GetBytes(csvcontent));
这些地方的编码问题
------解决方案--------------------
http://www.cnblogs.com/wf5360308/articles/621401.html
------解决方案--------------------
这里:
HttpContext.Current.Response.ContentType = "application/octet-stream ";
改成
Response.contentType= "application/vnd.ms-excel ";试试
------解决方案--------------------
mark...
------解决方案--------------------
Response.ContentType = "application/octet-stream ";
Response.AppendHeader( "Content-Disposition ", "attachment;filename= " + fileName);
int bufSize = (int)stream.Length;
byte[] buf = new byte[bufSize];
int bytesRead = stream.Read(buf,0,bufSize);
PatchData(buf, " ",position);
Response.OutputStream.Write(buf,0,bytesRead);
Response.End();
------解决方案--------------------
up
------解决方案--------------------
sign
------解决方案--------------------
看看吧~!经过测试 ~!可以翻页~!导出!
Response.Clear();
Response.Buffer = true;
Response.Charset= "GB2312 ";
Response.AppendHeader( "Content-Disposition ", "attachment;filename=SmsExcel.xls ");
Response.ContentEncoding=System.Text.Encoding.GetEncoding( "GB2312 ");//设置输出流为简体中文
Response.ContentType= "application/ms-excel ";
this.EnableViewState = false;
System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo( "ZH-CN ",true);
System.IO.StringWriter oStringWriter= new System.IO.StringWriter(myCItrad);
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new HtmlTextWriter(oStringWriter);
this.a.DataSource = this.GetDt();
this.a.DataBind();
this.a.RenderControl(oHtmlTextWriter);
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。
其他相似内容:
-
C#读取文本并入库
文本格式固定如下:
**********************:
<中文作者一>=赵逢玲
<中文作者二>=杜秀华
<中文作者三>=王翠东
<中...
-
C#操作Word文档(Office 2007)
首先引入类库,Microsoft.Office.Interop.Word,然后进行编程。代码如下:
using ...
-
请问,ReadLine方法读取文件
一个txt文件,有两行
aaaa
bbbb
代码:
string s1 = @"D:iosamplepp.txt";
using (StreamReader sr = new...
-
验证控件
在gridview页脚行添加了验证控件,可是点击编辑更新时触发了验证事件,无法更新,怎么办?
------解决方案-------------------...
-
在BITMAP上用GDI+画图,如何使画出的图像尽可能清晰?
我在一张bitmap上用GDI+绘制了简单的多边形,并用PictureBox显示。
我发现,如果我...
-
???如何利用webbrower获取ifream元素????
如何利用webbrower获取ifream元素.我在GOOGLE,BAIDU一整天依然无法找到解决方法!!希望各...
-
如何解决“已有打开的与此命令相关联的DataReader,必须首先将它关闭。”错误?
小弟写了一个DBHelper类来控制数据库访问,但是在实际...
-
在做asp.net项目时,在做数据库更新时出现',' 附近有语法错误。(数据库是用sql2000的)
数据库更新语句:
public void Update()
...
-
为什么我这段代码不会发出声音呢?
C# code
using System;
using System.Collections.Generic;
using System.ComponentModel;
usi...
-
ClickOnce 不支持请求执行级别requireAdministrator
写了一个应用程序,使用ServiceController控制 windows服务的的启动和停止。
...