asp.net导出成EXCEL
以下是导出的方法:
public static void ToExcel(System.Web.UI.Control ctl)
{
//HttpContext.Current.Response.Charset ="GB2312";
HttpContext.Current.Response.Charset = "GBK";
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=memory.xls");
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GBK");
HttpContext.Current.Response.ContentType = "application/ms-excel";//image/JPEG;text/HTML;image/GIF;vnd.ms-excel/msword
ctl.Page.EnableViewState = false;
System.IO.StringWriter tw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
ctl.RenderControl(hw);
HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.End();
}
在其它方法中调用:ToExcel(gridview1);
相关文档:
一般对于用过 动软.net代码生成器的人来说,省了好多事情。 model (实体层), dal(数据访问层), bll(业务逻辑层)
model 就不用说了 dal数据访问层有的时候要调用存储过程,以前很少写,觉得参数的调用挺费劲的,大家有什么好的办法能提高存储过程吗!!!!!!!!!! ......
static void Main(string[] args)
{
string connstr = "Data Source=***;user=system;password=***;";
OracleConnection conn = new OracleConnection(connstr);
conn.Open();
string orclstr="insert into SYS.A_MODULE values('03','查看生产任务','查看生产任务进度')";
  ......
Cookie 是什么?
在asp.net中,如何使用?
1 Cookie 是什么?
Cookie:电脑中记录用户在网络中的行为的文件;网站可通过Cookie来识别用户是否曾经访问过该网站。(摘自 http://gb.cri.cn/17004/2007/03/08/121@1487554.htm)
2在asp.net中,如何使用?
& ......
在web程序中,经常会使用在一个网页使用其他网页提交的数据信息,这里可以使用Request内置对象来完成,来获取用户提交的信息,根据客户端提交数据方式的不同,Request对象分别使用Form和QueryString集合属性来获取数据。下面是两种集合获取方式的不同点:通过Form获取数据时在form属性中简单的添加action=“跳转的网页 ......
The MVC bits have finally arrived and I’ve spent a while digesting them. I’ve been waiting for the bits to be released to begin working on a side-project, so the first thing I did after downloading them last night was crank it up and start working on a new ASP.NET MVC Web Application p ......