如何使用C#和Crystal Report创建具有多页的多子报表

时间:2016-03-29 04:36:34

标签: crystal-reports

DataSet mdsData = new DataSet("Dosage");

        DataTable table = new DataTable("table");
        table.Columns.Add("Dosage", typeof(int));
        table.Columns.Add("Drug", typeof(string));
        table.Columns.Add("Patient", typeof(string));
        table.Columns.Add("Date", typeof(DateTime));

        // Here we add five DataRows.
        table.Rows.Add(25, "Indocin", "David", DateTime.Now);
        table.Rows.Add(50, "Enebrel", "Sam", DateTime.Now);
        table.Rows.Add(10, "Hydralazine", "Christoff", DateTime.Now);
        table.Rows.Add(21, "Combivent", "Janet", DateTime.Now);
        table.Rows.Add(100, "Dilantin", "Melanie", DateTime.Now);

        AddTableToDataset(mdsData);

        ReportDocument rpt = new ReportDocument();

        rpt.Load("Report/rptMulti.rpt");
        mdsData.Tables.Add(table);
        //mdsData.Tables.Add(table1);
        mdsData.WriteXmlSchema("Schema/Dosage.xsd");


        CrystalDecisions.ReportAppServer.ReportDefModel.Section sec = rpt.ReportClientDocument.ReportDefController.ReportDefinition.ReportHeaderArea.Sections[0];
        rpt.ReportClientDocument.SubreportController.ImportSubreportEx("test1", "Report/6x10.rpt", sec, 100, 100, 7900, 5400);
        rpt.ReportClientDocument.SubreportController.ImportSubreportEx("test2", "Report/6x10.rpt", sec, 8080, 100, 7900, 5400);
        rpt.ReportClientDocument.SubreportController.ImportSubreportEx("test3", "Report/6x10.rpt", sec, 100, 5550, 7900, 5400);
        rpt.ReportClientDocument.SubreportController.ImportSubreportEx("test4", "Report/6x10.rpt", sec, 8070, 5550, 7900, 5400);


        rpt.Subreports["test1"].SetDataSource(mdsData.Tables["table"]);
        rpt.Subreports["test2"].SetDataSource(mdsData.Tables["table"]);
        rpt.Subreports["test3"].SetDataSource(mdsData.Tables["table"]);
        rpt.Subreports["test4"].SetDataSource(mdsData.Tables["table"]);

        frmView _frmReportMulti = new frmView(table, "VIE");
        _frmReportMulti.Show();
        _frmReportMulti.crystalReportViewer1.ReportSource = rpt;

report viewer

这是我在主报表上创建子报表和设置位置的代码。 目前我可以在一个页面上创建多个子报表, 我想在多页面上创建多个子报表,

请帮助我获得想法

0 个答案:

没有答案