/// /// 导出 /// /// /// public void ExportData() { string strTotal = ""; string title = ""; string meta = " "; StringBuilder builder = new StringBuilder(); builder.Append(meta); builder.Append("
"); builder.Append(" "); builder.Append(title + "(" + DateTime.Now.ToString("yyyy-MM-dd") + ")"); builder.Append(" |
"); builder.Append(" "); //builder.AppendFormat(" ID | "); //builder.AppendFormat(" "); //builder.AppendFormat(" | 动ID | "); builder.AppendFormat(" 名称 | "); //builder.AppendFormat(" 名人ID | "); builder.AppendFormat(" "); builder.AppendFormat(" | 部 | "); builder.AppendFormat(" 联方式 | "); builder.AppendFormat(" 他 | "); builder.Append("
"); builder.Append(strTotal); builder.Append("
"); System.Web.HttpContext.Current.Response.Clear(); HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(title + "" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls", Encoding.UTF8)); HttpContext.Current.Response.Charset = "UTF-8"; HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default; HttpContext.Current.Response.ContentType = "application/ms-excel"; HttpContext.Current.Response.Write("
"); // 把文件流发送到客户端 System.Web.HttpContext.Current.Response.Write(builder.ToString()); // 停止页面的执行 System.Web.HttpContext.Current.Response.End(); }