找回密码
 立即注册

QQ登录

只需一步,快速开始

15919418962

中级会员

5

主题

14

帖子

639

积分

中级会员

积分
639

活字格认证

最新发帖

[已处理] word,pdf导出

15919418962
中级会员   /  发表于:2013-9-18 11:42  /   查看:8281  /  回复:10
在word,pdf导出要怎样绑定相关的数据呢

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x

10 个回复

倒序浏览
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2013-9-18 15:09:00
沙发
请参考以下代码:

  1.     protected void btnWord_Click(object sender, EventArgs e)
  2.     {
  3.         SectionReport1 section = new SectionReport1();
  4.         section.UnboundDataSource = GetData1();
  5.         section.Run();

  6.         System.IO.MemoryStream ms = new System.IO.MemoryStream();
  7.         GrapeCity.ActiveReports.Export.Word.Section.RtfExport rtfExport = new GrapeCity.ActiveReports.Export.Word.Section.RtfExport();
  8.         rtfExport.Export(section.Document, ms);

  9.         Response.ContentType = "application/rtf";
  10.         Response.AddHeader("content-disposition", Server.UrlPathEncode("attachment;filename=客户订单.rtf"));
  11.         Response.BinaryWrite(ms.ToArray());
  12.         Response.End();
  13.     }

  14.     protected void btnPdf_Click(object sender, EventArgs e)
  15.     {
  16.         SectionReport1 section = new SectionReport1();
  17.         section.UnboundDataSource = GetData1();
  18.         section.Run();

  19.         System.IO.MemoryStream ms = new System.IO.MemoryStream();
  20.         GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport pdfExport = new GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport();
  21.         pdfExport.Export(section.Document, ms);

  22.         Response.ContentType = "application/pdf";
  23.         Response.AddHeader("content-disposition", Server.UrlPathEncode("attachment;filename=客户订单.pdf"));
  24.         Response.BinaryWrite(ms.ToArray());
  25.         Response.End();
  26.     }
复制代码
回复 使用道具 举报
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2013-9-18 15:15:00
板凳
同时,你可以参考这篇文章:http://blog.gcpowertools.com.cn/ ... _Client_Export.aspx
回复 使用道具 举报
15919418962
中级会员   /  发表于:2013-9-18 15:53:00
地板
好像还有点小问题,只能导出列名,但是内容没有导出来,这是为什么呢
回复 使用道具 举报
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2013-9-18 16:17:00
5#
有调用 section.Run();方法吗
回复 使用道具 举报
15919418962
中级会员   /  发表于:2013-9-18 16:19:00
6#
有的,在MVC框架下是只出现列名,但是内容就是显示不出来
回复 使用道具 举报
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2013-9-18 16:27:00
7#
能发个完整的示例程序给我调试一下嘛,这样调查起来会快一些。
回复 使用道具 举报
15919418962
中级会员   /  发表于:2013-9-21 18:14:00
8#
已经处理好了
回复 使用道具 举报
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2013-9-22 10:14:00
9#
谢谢,反馈。
回复 使用道具 举报
gxfmmm
注册会员   /  发表于:2014-10-11 10:22:00
10#
你好,为什么我导出的WORD表格全没有了,换行也有问题
回复 使用道具 举报
12下一页
您需要登录后才可以回帖 登录 | 立即注册
返回顶部