,于是就自己整理写了一个,给象我一样的菜鸟们,如果正在学Asp.net2.0的同僚们可以看看阿!高手不要见笑哦!
GridView实用源码(可以导出Excel) VS2005中GridView的自定义分页,单选、多选、排序、自增列及可以导出Excel的简单应用源码多选时,只有全部选中时“多选”才选中
导出Excel部分的源码
//导出到Execl
protected void Button3_Click(object sender, EventArgs e)
{
Response.ClearContent();
Response.AddHeader("content-disposition", "attachment; filename=MyExcelFile.xls");
Response.ContentType = "application/excel";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
GridView1.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
}
protected void Button3_Click(object sender, EventArgs e)
{
Response.ClearContent();
Response.AddHeader("content-disposition", "attachment; filename=MyExcelFile.xls");
Response.ContentType = "application/excel";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
GridView1.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
}
本文转自 liudao 博客园博客,原文链接:http://www.cnblogs.com/liudao/archive/2007/04/24/725571.html,如需转载请自行联系原作者