简体   繁体   English

如何从数据表向水晶报表添加多行

[英]how to add multiple rows from datatable to crystal report

I have a datatable with multiple rows. 我有一个多行数据表。 I want to bind this datatable to a crystal report . 我想将此数据表绑定到水晶报表。

How is it possible? 这怎么可能?

        Dsprint.Tables.Clear();
        Dsprint.Tables.Add(dtTitle);
        Dsprint.Tables.Add(dtitem);
        ReportDocument Rpt = new ReportDocument();
        string filepath = Application.StartupPath.Replace("bin\\Debug", "") +                   @"\CrystalReports\CryDayReport.rpt";
        Rpt.Load(filepath);
        frmCrystalReportViewer newReportViewer = new frmCrystalReportViewer();
        Rpt.SetDataSource(Dsprint);
        Dsprint.WriteXmlSchema(Environment.CurrentDirectory + "\\DayReport.xsd");
        newReportViewer.crViewer.ReportSource = Rpt;
        newReportViewer.ShowDialog();

You have two options 你有两个选择

1) Using Grouping 1)使用分组

In this you can create group in Crystal report by ID and Suppress If Duplicate in this field's Property. 在此您可以按ID在Crystal报表中创建组,并在此字段的“属性”中禁止“如果重复”。

2)Suppress if Duplicate. 2)禁止重复。

If Data is Order by ID then this option is also good. 如果“数据是按ID排序”,则此选项也不错。 Just Right click id field and Select Property and check suppress if Duplicate. 只需右键单击id字段并选择Property,然后检查是否重复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM