紧急求助页面上的表格导入到excel的问题

117hn 2007-11-12 08:43:55
各位大侠,我遇到这样的问题,我在页面上放了一个Label控件,在后台对这个Label进行赋值,内容为表格的HTML代码,根据查询到的数据库内容进行循环显示,最终在页面上显示出来三个表格一样,但是内容不一样的table表格,
我导入到EXCEL里面后发现,excel里面只有中间的那个表格内容,而第一个和第三个都没有,我很奇怪,不知道是那个地方出错了,页面的确显示的是三个表格呀,为什么导入excel里面就只有中间的一个表格内容了,请各位高手帮我看看,谢谢。
以下是导入代码
//设置输出类型是Excel
Response.AppendHeader("content-disposition", "filename=output.xls");
Response.ContentType = "application/vnd.ms-excel";

//将表格内容作为Excel输出
System.IO.StringWriter sw=new System.IO.StringWriter();
HtmlTextWriter htwVehicleList=new HtmlTextWriter(sw);
this.Page.RenderControl(htwVehicleList);
Response.Write(sw.ToString());
Response.End();
...全文
108 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
fang1572 2007-12-04
  • 打赏
  • 举报
回复
jf,楼上把怎么解决的方法也贴出来,大伙一起学习下啊
qawszx 2007-12-04
  • 打赏
  • 举报
回复
恭喜你自己解决问题哈
那就接分喽
maoning 2007-12-04
  • 打赏
  • 举报
回复
我这么用的 一直挺好
Response.Clear();
Response.Buffer = true;
Response.Charset = "GB2312 ";
Response.ContentType = "application/ms-excel ";//vnd.xls";
Response.ContentEncoding = System.Text.Encoding.UTF7;
Response.AddHeader("content-disposition", "attachment;filename="+ Server.UrlPathEncode("评委密码.xls"));
// If you want the option to open the Excel file without saving than comment out the line below
// Response.Cache.SetCacheability(HttpCacheability.NoCache);
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
// turn off paging
//bindGridView();
GridView1.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.Flush();
Response.End();
117hn 2007-12-04
  • 打赏
  • 举报
回复
我已经换个思路解决了问题,欢迎大家进来接分
lovelizheng 2007-11-12
  • 打赏
  • 举报
回复
1,3数据为空吧?
kidfang 2007-11-12
  • 打赏
  • 举报
回复
好!
JF
ojekleen 2007-11-12
  • 打赏
  • 举报
回复
mark,
ljmay168 2007-11-12
  • 打赏
  • 举报
回复
导出数据时有没有重新绑定数据?

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧