当前位置: 代码迷 >> ASP.NET >> 跪求!asp.net下载功能实现的代码!
  详细解决方案

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

热度:4036   发布时间:2013-02-26 00:00:00.0
跪求!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
  相关解决方案