日期:2014-05-20  浏览次数:20390 次

跪求!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