Logo Questions Linux Laravel Mysql Ubuntu Git Menu

How do I programmatically import a Crystal Reports SubReport into a Report Section in Visual Studio 2010

I have a Crystal Report object defined as follows:

private CrystalDecisions.CrystalReports.Engine.ReportClass rep;

I am trying to Import a SubReport into Section 1 of the report. I have tried variants of the following code: rep.ReportClientDocument.SubreportController.ImportSubreport

There seems to be conflict between:




Has anybody programmatically imported a Sub-Report in Crystal using VS2010?

like image 467
Ian Edwards Avatar asked Nov 14 '22 22:11

Ian Edwards

1 Answers

For anybody else who comes across this problem, the solution is:

            CrystalDecisions.CrystalReports.Engine.ReportClass rep;
            ReportClientDocumentWrapper doc = (ReportClientDocumentWrapper)rep.ReportClientDocument;
            CrystalDecisions.ReportAppServer.ReportDefModel.Section sec = doc.ReportDefController.ReportDefinition.ReportHeaderArea.Sections[0];
            doc.SubreportController.ImportSubreport("SubReport", csr.ReportFileName, sec);
like image 189
Ian Edwards Avatar answered Dec 22 '22 10:12

Ian Edwards