日期:2014-05-17  浏览次数:20958 次

关于日志导出!
第一次做日志导出,请问大家怎么写代码啊,别怪我直接求代码啊,白的厉害。具体就是把一个texbox中的内容导出,以时间命名,、。。。。。。。。求了

------解决方案--------------------
这是一段 public void ReportToExcel(GridView dd, int i)
{
string sname = "报表.xls";
HttpContext.Current.Response.Charset = "GB2312";

HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
HttpContext.Current.Response.ContentType = "application/ms-excel";


HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(sname, System.Text.Encoding.UTF8));
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
if (i == 3)
{
dd.RenderControl(htw);
}
HttpContext.Current.Response.Write(sw.ToString());
HttpContext.Current.Response.Write("打印日期:" + DateTime.Now.ToString());

HttpContext.Current.Response.End();
}

自己参考下吧