找回密码
 立即注册

QQ登录

只需一步,快速开始

Wanreds

中级会员

2

主题

7

帖子

574

积分

中级会员

积分
574

活字格认证

最新发帖
Wanreds
中级会员   /  发表于:2012-4-20 13:28  /   查看:6999  /  回复:6
画好报表后,根据数据开始打印报表。
循环数据,把每一页报表上的数据都填满后,这页报表的对象就保存起来。全部数据处理完后,可能会有多个报表对象(因为会打印多页)。最后这些报表对象如何合并成一个报表对象一次打印出来呢?

6 个回复

倒序浏览
iceman
社区贡献组   /  发表于:2012-4-20 14:34:00
沙发

回复 1# Wanreds 的帖子

Wanreds 你好,
可以以其中一个报表作为主报表。其他报表作为该主报表的 SubReport 添加,如果需要打印到不同页,可以添加 Page Break 进行分页。
回复 使用道具 举报
Wanreds
中级会员   /  发表于:2012-4-20 15:20:00
板凳
具体到代码的话,怎么实现合并呢?
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2012-4-20 17:13:00
地板

回复 3# Wanreds 的帖子

Wanreds 你好,
1.下面是实现 SubReport 代码:

  1. //添加 SubReport
  2.             Field subReportField = this._c1r.Fields["SubreportField"];
  3.             C1Report subReport = new C1Report();
  4.             subReport.Load("filename", "reportname");
  5.             subReportField.Subreport = subReport;

  6.             //把 SubReport 添加到 PageFooter 位置
  7.             subReportField.Section = SectionTypeEnum.PageFooter;

  8.             //设置在 SubReport 之前换页
  9.             this._c1r.Sections["PageFooter"].ForcePageBreak = ForcePageBreakEnum.Before;

复制代码

2.楼主还可以参考 C1 随机安装的 Demo:
Documents\ComponentOne Samples\Studio for WinForms\C1Report\C1Report\Cs\SubReportDataSource
回复 使用道具 举报
Wanreds
中级会员   /  发表于:2012-4-24 09:10:00
5#
谢谢版主的回答。

subReportField是否要预先在报表里画好的呢?能否在代码里动态实现呢?因为如果SubReport个数不固定的话,没法在报表里预先画好。
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2012-4-24 18:17:00
6#

回复 5# Wanreds 的帖子

Wanreds 你好,
不好意思,该问题正在处理中,明天回复。
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2012-4-25 12:27:00
7#
Wanreds 你好,
C1Report Filed 是可以动态添加的例如:

  1. C1.C1Report.Field test = new C1.C1Report.Field();
  2.             test.Subreport = this.c1Report1;
  3.             this.c1Report1.Fields.Add(test);
复制代码
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部