求datagrid导出到txt的代码 求datagrid导出到txt的代码,请高手帮忙!谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://topic.csdn.net/t/20060221/16/4568625.html 上面的好象是导到excel,有没有导入txt的? 其实是一样的/// <summary> /// 导出为 Excel 函数 /// </summary> /// <param name="ctl"></param> /// <param name="FileName"></param> public static void ToExcel(System.Web.UI.Control ctl, string FileName) { HttpContext.Current.Response.Charset = "utf-8"; HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default; HttpContext.Current.Response.ContentType = "application/ms-excel"; //response.contenttype指定文件类型 可以为application/ms-excel、application/ms-word、application/ms-txt、application/ms-html 或其他浏览器可直接支持文档 HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + "" + FileName + ".xls"); //filename=fileflow.xls 指定输出文件的名称,注意其扩展名和指定文件类型相符,可以为:.doc .xls .txt .htm ctl.Page.EnableViewState = false; System.IO.StringWriter tw = new System.IO.StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(tw); ctl.RenderControl(hw); HttpContext.Current.Response.Write(tw.ToString()); HttpContext.Current.Response.End(); } 做URL重写的时候使用正则表达式进行匹配遇到的一点点问题 菜鸟学.NET 关于Session["UserName"] = name;问题 关于连接access路径问题 请问一个让人迷惑的问题 表单提交问题 谁能给我一个论坛发贴子的支持在线编辑框和输出格式化的源代码? 大家看看这个问题,可能不难,但是困扰了我许久了, 新手上路:用什么软件写ASP.Net? 关于 @Html.CheckBox 求教!象我这样的水平毕业论文应该怎么写呀! 有几个关于数据绑定的问题请高手帮忙指点一下 谁有电子书下载地址啊,谢谢
/// 导出为 Excel 函数
/// </summary>
/// <param name="ctl"></param>
/// <param name="FileName"></param>
public static void ToExcel(System.Web.UI.Control ctl, string FileName)
{
HttpContext.Current.Response.Charset = "utf-8";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default;
HttpContext.Current.Response.ContentType = "application/ms-excel"; //response.contenttype指定文件类型 可以为application/ms-excel、application/ms-word、application/ms-txt、application/ms-html 或其他浏览器可直接支持文档
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + "" + FileName + ".xls"); //filename=fileflow.xls 指定输出文件的名称,注意其扩展名和指定文件类型相符,可以为:.doc .xls .txt .htm
ctl.Page.EnableViewState = false;
System.IO.StringWriter tw = new System.IO.StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
ctl.RenderControl(hw);
HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.End();
}