DataGrid输出到Excel的问题,高手们帮帮忙 DataGrid输出到Excel可以实现。但是如果DataGrid有分页的话要如何实现呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 建议你去http://www.cnblogs.com/birdshome/favorite/1666.html这里前面的一篇文章不错,我就是用他的代码来做的 protected void lbExport_Click(object sender, EventArgs e) { ExportToExcel(dgExport); } private void ExportToExcel(Control ctrl) { Response.AppendHeader("Content-Disposition", "attachment;filename=Excel.xls"); Response.ContentEncoding = Encoding.GetEncoding("GB2312"); Response.ContentType = "application/ms-excel"; StringWriter tw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(tw); ctrl.RenderControl(hw); Response.Write(tw.ToString()); Response.End(); } doitnow2000(大海) 这个代码,如果分页的话会出错吧 to wkxgyg:数据源输出是最好的,而且我上面不是提供了方法页面么? jimu8130(好累好累) 我看到了,里面好多个啊,具体是哪个? to wkxgyg:就是第一个啊?他连源代码都公布了 to wkxgyg:上面不是有很多相关的导出excel的文章,你仔细看看 将html、js代码过滤后,css代码怎么过滤?采集系统 ASP.ENT中的数据库连接问题 使用reportviewer添加不了数据源 网页模板 fckeditor 404错误 数据源不支持服务器端的数据分页???? 视金钱如生命,视生命如戏,视戏如金钱 文本框TextBox在页面加载时自动获得焦点 快来帮忙看网站有木有bug 急求:.net1.1 验证控件在firefox中失效 关于asp.net的session的写入和读取的疑问. 很简单的一个功能,就是不知道怎么实现,请教了
这里前面的一篇文章不错,我就是用他的代码来做的
{
ExportToExcel(dgExport);
}
private void ExportToExcel(Control ctrl)
{
Response.AppendHeader("Content-Disposition", "attachment;filename=Excel.xls");
Response.ContentEncoding = Encoding.GetEncoding("GB2312");
Response.ContentType = "application/ms-excel"; StringWriter tw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw); ctrl.RenderControl(hw);
Response.Write(tw.ToString());
Response.End();
}
这个代码,如果分页的话会出错吧
数据源输出是最好的,而且我上面不是提供了方法页面么?
我看到了,里面好多个啊,具体是哪个?