为了账号安全,请及时绑定邮箱和手机立即绑定

用GridViewt生成如下图的表格,用C#

用GridViewt生成如下图的表格,用C#

一只斗牛犬 2018-11-07 05:02:10
GridView gridview = new GridView();                gridview.DataSource = dt;                gridview.DataBind();                string filename = LevelSupBaseInfoDropDownList.SelectedItem.Text;                Response.Clear();                Response.Buffer = true;                Response.Charset = "GB2312";                Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlPathEncode(filename + ".xls"));                Response.ContentEncoding = System.Text.Encoding.UTF7;                Response.ContentType = "application/ms-excel";                System.IO.StringWriter oStringWriter = new System.IO.StringWriter();                System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);                gridview.RenderControl(oHtmlTextWriter);                Response.Output.Write(oStringWriter.ToString());                Response.Flush();                Response.End();
查看完整描述

2 回答

?
偶然的你

TA贡献1841条经验 获得超3个赞

使用向客户端输出的js的方式,这个也可以任意指定样式和格式。这个需要ie允许ActiveX

查看完整回答
反对 回复 2018-11-12
  • 2 回答
  • 0 关注
  • 512 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信