admin = Context.Request.Cookies["user"].Values["username"].ToString();
Hashtable hash = new Hashtable(); hash.Add("p2", admin); hash.Add("p_state", 2); //DataSet ds = Bll.ProjectInfoBll.SelectAll_state(hash) as DataSet; //DataTable dt = ds.Tables[0]; //ViewState["DtDatat"] = ds.Tables[0]; Repeater1.DataSource = Bll.ProjectInfoBll.SelectAll_state(hash); this.Repeater1.DataBind(); string strnum = DateTime.Now.ToString("F"); //CreateExcel(tmbll, strnum + ".xls"); HttpResponse response = Page.Response; Response.Clear(); Response.Buffer = true; Response.Charset = "utf-8"; //解决导出到Excel2007乱码问题 Response.Write("<meta http-equiv=Content-Type content=text/html;charset=GB2312>"); Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(strnum, System.Text.Encoding.UTF8) + ".xls"); //解决导出到Excel2007乱码问题 //解决导出到Excel2007乱码问题 Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");(这个是关键) //Response.ContentEncoding = System.Text.Encoding.UTF8; //设置输出流为简体中文 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); // repeater控件的ID Repeater1.RenderControl(oHtmlTextWriter); Response.Write(oStringWriter.ToString()); Response.End();