.net中的数据怎么导出成excel文件? .net中的数据怎么导出成excel文件? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 并清楚你说的是.NET导出是什么,页面导出?控件中的数据导出?这里有一个DATAGRID导出EXCEL的方法,作为参考if(this.dgData.Items.Count==0) { RegisterStartupScript("Error","<script>alert('对不起,你没有查询到任何记录,不能导出数据')</script>"); } else { Response.Clear(); Response.Buffer= true; Response.Charset="GB2312"; Response.AppendHeader("Content-Disposition","attachment;filename=FileName.xls"); Response.ContentEncoding=System.Text.Encoding.GetEncoding("GB2312"); //设置输出流为简体中文 Response.ContentType = "application/ms-excel"; //设置输出文件类型为excel文件。 this.EnableViewState = false; System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("ZH-CN",true); System.IO.StringWriter oStringWriter = new System.IO.StringWriter(myCItrad); System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter); this.dgData.RenderControl(oHtmlTextWriter); Response.Write(oStringWriter.ToString()); Response.End(); } asp.net操作Excel总结 http://renyu732.cnblogs.com/archive/2005/06/15/174866.html 兄弟,网络资源很丰富,学会搜索!http://www.cnblogs.com/lovecherry/archive/2005/03/25/125519.html 这些是什么编码 一个非常奇怪的问题 asp.net的验证码问题 如何做一个最简单的WEB服务器控件 如何实现竖型下拉菜单? 请问怎么才能让单号重复时两个数据库都不录入 视频怎么做啊,用摄像头 只用asp.net不用javascript可以吗? oracle数据库中有些表是乱码,不知如何解决! 怎样在VB6中调用WEB服务! 几个问题, 请各位帮忙!我才130分,送100分! 请教大虾:怎么获取最后插入数据的标识值?
{
RegisterStartupScript("Error","<script>alert('对不起,你没有查询到任何记录,不能导出数据')</script>");
}
else
{
Response.Clear();
Response.Buffer= true;
Response.Charset="GB2312";
Response.AppendHeader("Content-Disposition","attachment;filename=FileName.xls");
Response.ContentEncoding=System.Text.Encoding.GetEncoding("GB2312");
//设置输出流为简体中文
Response.ContentType = "application/ms-excel";
//设置输出文件类型为excel文件。
this.EnableViewState = false;
System.Globalization.CultureInfo myCItrad = new System.Globalization.CultureInfo("ZH-CN",true);
System.IO.StringWriter oStringWriter = new System.IO.StringWriter(myCItrad);
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
this.dgData.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();
}
http://renyu732.cnblogs.com/archive/2005/06/15/174866.html
http://www.cnblogs.com/lovecherry/archive/2005/03/25/125519.html