读书人

跪求!asp.net下载功能实现的代码!

发布时间: 2012-03-25 20:55:17 作者: rapoo

跪求!asp.net下载功能实现的代码!!在线等
主要就是实现在网页上保存数据库的数据到本地的Excel文件中去。


[解决办法]
public static void GenerateByHtmlString(string Typename, string TempHtml)
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.Charset = "utf-8 ";
string Filename = Typename + ".xls ";
HttpContext.Current.Response.AppendHeader( "Content-Disposition ", "online;filename= " + Filename);
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding( "utf-8 ");
HttpContext.Current.Response.ContentType = "application/ms-excel ";
//this.EnableViewState = false;
HttpContext.Current.Response.Write(TempHtml);
HttpContext.Current.Response.End();
}

Typename: 为文件名
TempHtml: 把数据库中数据配置成Html放到此变量中
[解决办法]
http://blog.csdn.net/jxufewbt/archive/2006/04/21/671406.aspx

读书人网 >asp.net

热点推荐