System.Web.HttpContext context = System.Web.HttpContext.Current;
string style = @"<style> .text { mso-number-format:\@; } </script> ";
context.Response.Clear();
context.Response.AddHeader("Content-Disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode(txtFileName + DateTime.Now.ToShortDateString(), System.Text.Encoding.UTF8) + ".xls");
context.Response.Charset = "GB2312";
context.Response.ContentType = "application/excel";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); GridView1.Visible = true;
GridView1.AllowPaging = false;
GridView1.DataBind();
GridView1.RenderControl(htmlWrite); context.Response.Write(style); context.Response.Write(stringWrite.ToString());
context.Response.End();
读取出来有乱码,不知道怎么回事,高手帮忙解决下
string style = @"<style> .text { mso-number-format:\@; } </script> ";
context.Response.Clear();
context.Response.AddHeader("Content-Disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode(txtFileName + DateTime.Now.ToShortDateString(), System.Text.Encoding.UTF8) + ".xls");
context.Response.Charset = "GB2312";
context.Response.ContentType = "application/excel";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); GridView1.Visible = true;
GridView1.AllowPaging = false;
GridView1.DataBind();
GridView1.RenderControl(htmlWrite); context.Response.Write(style); context.Response.Write(stringWrite.ToString());
context.Response.End();
读取出来有乱码,不知道怎么回事,高手帮忙解决下
SqlCommand com = new SqlCommand(sql, con);
SqlDataAdapter da = new SqlDataAdapter(com);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
这样的连接有什么不对么