求教repeater 导出EXCEL,导出后前十五行为空白如何去除

忙里偷着乐 忙里偷着乐 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
如题,代码如下。先谢谢,找了好长时间没有一个很好的解决办法。转换成HTML格式。是没有空白区域的。和CSS样式无关
System.IO.StringWriter sw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(sw);
this.Repeater1.RenderControl(hw);

Response.Clear();
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
Page.EnableViewState = false;

Response.AppendHeader("Content-Disposition", "attachment;filename=" + sDayTime.Text + "—" + eDayTime.Text + "按年统计报表.xls");
string html = "<html><head><meta http-equiv=Content-Type content=\"text/html; charset=GB2312\"><link href=\"http://" + Request.Url.Authority + "/_media/css/Frame.css\" type=\"text/css\" rel=\"stylesheet\" /> <style>td{line-height:1;}</style><title>报表</title></head><body >";
html += sw.ToString();
html += "</body></html>";
Response.Write(html);
Response.End();
...全文

相关推荐

评论 5
收藏 已收藏
分享
返回顶部
忙里偷着乐
.NET社区 62,271 成员 668,968 内容