易截截图软件、单文件、免安装、纯绿色、仅160KB

asp.net将页面中gridview中的数据导入excel表中

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
namespace AJAXEnabledWebApplication1
{
public partial class excelOutput : System.Web.UI.Page
{
DBClass db = new DBClass();
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
string strsql = "select * from TreeViewTemp where parentID=0";
DataTable dt = db.GetDataTable(strsql);
this.GridView1.DataSource = dt;
this.GridView1.DataBind();
}
}
protected void Button1_Click(object sender, EventArgs e)
{

OutPutExcel();
}
//此处要注意,这个重载方法,一定要写,不然会报类型“GridView”的控件“GridView1”必须放在具有 runat=server 的窗体标记内
public override void VerifyRenderingInServerForm(Control control)
{
}
public void OutPutExcel()
{
//定义文档类型、字符编码
Response.Clear();
Response.Buffer = true;
Response.Charset = "GB2312";
//下面这行很重要, attachment 参数表示作为附件下载,您可以改成 online在线打开
//filename=FileFlow.xls 指定输出文件的名称,注意其扩展名和指定文件类型相符,可以为:.doc    .xls    .txt   .htm
Response.AppendHeader("Content-Disposition", "attachment;filename=FileFlow.xls");
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
//Response.ContentType指定文件类型 可以为application/ms-excel、application/ms-word、application/ms-txt、application/ms-html 或其他浏览器可直接支持文档


相关文档:

google suggest 下拉菜单(asp.net/jQuery版本)

suggest.js文件(在引入suggest.js文件前需要先引入jquery-1.4.2.min.js):
 $(function() {
var k = -1;
//给查询文本框绑定click keyup事件,进行这两个事件,自动查询数据
$("#FrmChangshang").bind('click keyup', function(event) {
//获取键盘操作事件代码
var keyc = event ......

Mix 10 上的asp.net mvc 2的相关Session

Beyond File | New Company: from Cheesy Sample to Social Platform Scott Hanselman in Lagoon L on Monday at 11:30 AM The web has changed and there's a new way of thinking about your applications. You can't just write some HTML and CSS anymore and expect to be the next Twitter. Hear h ......

Online active users counter in ASP.NET


Online active users counter in ASP.NET
With this tool which is written for ASP.NET, it is possible to count the number of online users, members and guest users in web sites.
Installation
The tool installation is very simple and only takes a few minutes.
Step one - Add Reference:
After downlo ......

使用WebClient自动填写并提交ASP.NET页面表单


使用WebClient自动填写并提交ASP.NET页面表单
      在.NET中通过程序填写和提交表单还是比较简单。比如,要提交一个如下图所示的登录表单:
           
填写和提交以上表单的代码如下:
      &nb ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号