水晶报表--动态添加子报表

1,创建DataSet

2,将字段绑定(拖动)到子报表

3,将子报表加入到主报表中(省略了主报表部分的初始化)

             // create the relation of main report and the child report
            ISCDReportClientDocument rptClientDoc  =  _rptContainerDoc.ReportClientDocument;
            
// Section define the character of this Section.
            
//  it contains type, name, width, height and so on.
            CrystalDecisions.ReportAppServer.ReportDefModel.Section xSection  =   new  CrystalDecisions.ReportAppServer.ReportDefModel.Section();
            xSection.Kind 
=  CrystalDecisions.ReportAppServer.ReportDefModel.CrAreaSectionKindEnum.crAreaSectionKindReportFooter;
            xSection.Name 
=   " xxx " ;
            xSection.Width 
=   567   *   10 ;
            xSection.Height 
=   567   *   20 ;

            
// position and import report file
            CrystalDecisions.ReportAppServer.ReportDefModel.ISCRArea xArea  =  rptClientDoc.ReportDefController.ReportDefinition.ReportFooterArea;
            rptClientDoc.ReportDefController.ReportSectionController.Add(xSection, xArea, 
- 1 );
            SubreportClientDocument subRptClientDoc 
=  rptClientDoc.SubreportController.ImportSubreport( " test " , strPath, xSection);

            
// Section define the character of this Section.
            CrystalDecisions.ReportAppServer.ReportDefModel.Section xSection2  =   new  CrystalDecisions.ReportAppServer.ReportDefModel.Section();
            xSection2.Kind 
=  CrystalDecisions.ReportAppServer.ReportDefModel.CrAreaSectionKindEnum.crAreaSectionKindReportFooter;
            xSection2.Name 
=   " xxxg " ;
            xSection2.Width 
=   567   *   10 ;
            xSection2.Height 
=   567   *   20 ;

            
// position and import report file
            rptClientDoc.ReportDefController.ReportSectionController.Add(xSection2, xArea,  - 1 );
            subRptClientDoc 
=  rptClientDoc.SubreportController.ImportSubreport( " test22 " , strPath, xSection2);


            DataSetSingle dsSingle 
=   new  DataSetSingle();
            dsSingle.tblSingle.AddtblSingleRow(
" 1 " " 111 " );
            dsSingle.tblSingle.AddtblSingleRow(
" 2 " " 222 " );
            dsSingle.tblSingle.AddtblSingleRow(
" 3 " " 333 " );
            dsSingle.tblSingle.AddtblSingleRow(
" 4 " " 444 " );
            
// subRptClientDoc.DatabaseController.AddDataSource(DataSetConverter.Convert(dsSingle));
            
// visit child reports and databind
            _rptContainerDoc.Subreports[ 0 ].SetDataSource(dsSingle);

            dsSingle.tblSingle.AddtblSingleRow(
" 1 " " 111 " );
            dsSingle.tblSingle.AddtblSingleRow(
" 2 " " 222 " );
            dsSingle.tblSingle.AddtblSingleRow(
" 3 " " 333 " );
            dsSingle.tblSingle.AddtblSingleRow(
" 4 " " 444 " );
            
/// /visit child reports and databind
            _rptContainerDoc.Subreports[ 1 ].SetDataSource(dsSingle);

转载于:https://www.cnblogs.com/transcom/archive/2008/12/02/1346168.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值