如题,代码如下。先谢谢,找了好长时间没有一个很好的解决办法。转换成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();