水晶报表如何用代码动态添加子报表,是用代码... 代码.......

叫我猫爷_ 2014-03-04 05:40:40

报表A,报表B,报表C

假设有这3个报表..

ReportDocument rd = new ReportDocument();


rd是上面3个报表的主报表..
怎么才能把报表B,C或报表A,B,C添加到rd的子报表呢.?
代码.. 是用代码.. 因为有可能报表太多了. 不能预先设计好.. 只能动态添加..
求大牛来解答..
...全文
341 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
熙风 2014-03-06
  • 打赏
  • 举报
回复
引用 10 楼 lerbornjames 的回复:
[quote=引用 3 楼 happy09li 的回复:] http://www.cnblogs.com/freeliver54/archive/2011/03/22/1991258.html
问一下,ABC三个报表. A是主报表, 我要帮B,C里面的参数字段绑定数据.. 我用A.Subreports["B"].SetParameterValue("xxx","yyy"); 这样来绑定报错了,报了一个叫子报表中不支持的错. [/quote] 设置成字段赋值看下 TextObject txx; txx = (TextObject)rpt.Subreports[childName].ReportDefinition.ReportObjects["Text5"]; txx.Text = "123";
叫我猫爷_ 2014-03-06
  • 打赏
  • 举报
回复
引用 3 楼 happy09li 的回复:
http://www.cnblogs.com/freeliver54/archive/2011/03/22/1991258.html
问一下,ABC三个报表. A是主报表, 我要帮B,C里面的参数字段绑定数据.. 我用A.Subreports["B"].SetParameterValue("xxx","yyy"); 这样来绑定报错了,报了一个叫子报表中不支持的错.
熙风 2014-03-06
  • 打赏
  • 举报
回复
引用 13 楼 lerbornjames 的回复:
[quote=引用 11 楼 happy09li 的回复:]
如图,这个 其他加工要求 这栏有可能很多数据,那么如果不设置可以增大就会超过的不显示,如果设置了可以增大,那么超过的数据就会突出来.. 好难看,这个框框能不能也设置成可以增大.?[/quote] 你把那个字段设置成可以换行显示就行了
叫我猫爷_ 2014-03-06
  • 打赏
  • 举报
回复
引用 11 楼 happy09li 的回复:


如图,这个 其他加工要求 这栏有可能很多数据,那么如果不设置可以增大就会超过的不显示,如果设置了可以增大,那么超过的数据就会突出来.. 好难看,这个框框能不能也设置成可以增大.?
叫我猫爷_ 2014-03-06
  • 打赏
  • 举报
回复
引用 11 楼 happy09li 的回复:
[quote=引用 10 楼 lerbornjames 的回复:] [quote=引用 3 楼 happy09li 的回复:] http://www.cnblogs.com/freeliver54/archive/2011/03/22/1991258.html
问一下,ABC三个报表. A是主报表, 我要帮B,C里面的参数字段绑定数据.. 我用A.Subreports["B"].SetParameterValue("xxx","yyy"); 这样来绑定报错了,报了一个叫子报表中不支持的错. [/quote] 设置成字段赋值看下 TextObject txx; txx = (TextObject)rpt.Subreports[childName].ReportDefinition.ReportObjects["Text5"]; txx.Text = "123";[/quote] 目测可以.
  • 打赏
  • 举报
回复
我以为是要我们来帮你攻击小喇叭呢
水猿兵团五哥 2014-03-05
  • 打赏
  • 举报
回复
引用 5 楼 lerbornjames 的回复:
[quote=引用 2 楼 u012173239 的回复:]
这段代码我也百度出来了,看不懂.[/quote] 那个代码可以哦,就是添加子报表,设置报表样式啥的啊
本拉灯 2014-03-04
  • 打赏
  • 举报
回复
只会FastReport任意什么样的报表都搞出来了,主从表更不用说了,还有奇葩的行列合并什么的,无规则的表格。。 只能说帮顶。
叫我猫爷_ 2014-03-04
  • 打赏
  • 举报
回复
引用 2 楼 u012173239 的回复:
这段代码我也百度出来了,看不懂.
叫我猫爷_ 2014-03-04
  • 打赏
  • 举报
回复
引用 3 楼 happy09li 的回复:
http://www.cnblogs.com/freeliver54/archive/2011/03/22/1991258.html
大概注意事项: 1.确定主报表中子报表的名称与动态加载报表的名称一样 2.子报表加载数据的事件在加载子报表流的后面 3.报表要重新Reset并处理过Refresh 第一条满足不了.. 这怎么办.?
Landa_Jimmy 2014-03-04
  • 打赏
  • 举报
回复
//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);
___________小P 2014-03-04
  • 打赏
  • 举报
回复
我不知道啊 来接分的

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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