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);
相关文档:
1.<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
Vs2005红色了,提示找不到该文件
于是改为.<script src="/Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
结果红色没有了,但是编译时报错,找不到该文件
结论:<script src="Script ......
1.只要求保留N位不四舍5入
float f = 0.55555f;int i =(int)(f * 100);f = (float)(i*1.0)/100;
2.保留N位,四舍五入 .
decimal d= decimal.Round(decimal.Parse("0.55555"),2);
3.保留N位四舍五入
Math.Round(0.55555,2)
4,保留N位四舍五入
double dbdata = 0.5 ......
ASP.NET的内置对象介绍
1.Response
2.Request
3.Server
4.Application
5.Session
6.Cookie
Request对象主要是让服务器取得客户端浏览器的一些数据,包括从HTML表单用Post或者GET方法传递的参数、Cookie和用户认证。因为Request对象是Page对象的成员之一,所以在程序中不需要做任何的声明即可直接使用;其类名为 HttpR ......
应用1:GridView和CheckBox结合
效果图:
应用2:Extending the GridView Control
Code download available at: CuttingEdge05.exe (132 KB)
Browse the Code Online
Contents
The GridView Difference
A New GridView Control
Adding a Checkbox Column
The New Grid In Action
Styling Selected ......