首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

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

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

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

热点排行