Quantcast
Channel: SCN : Discussion List - SAP Crystal Reports, version for Visual Studio
Viewing all articles
Browse latest Browse all 3636

How to modify sub-report location with C#

$
0
0

Hi,

 

Is it possible to modify sub-report location with C#?

 

I use the following code to retrieve the locations of sub-reports. What if I need to update the SubreportLocation and save it back to the main template report?


We need this for our production deployment. Let's say we have two sets of Crystal reports, Dev and Prod. All Dev templates are stored in C:\Dev and all sub-reports are in C:\Dev\SubReport. All Prod templates and sub-reports are stored in C:\Prod and C:\Prod\SubReport. If we need to update a template, we will do it in Dev and test it, then deploy to Prod. What is the best way to do the deployment? We don't want to update all sub-report locations every time. I don't think sub-report location suppports relative path right?

 

               ISCDReportClientDocument rptClientDoc = cryRpt.ReportClientDocument;

            var rptObjs = cryRpt.ReportClientDocument.ReportDefController.ReportObjectController.GetAllReportObjects();

 

 

            var textBox1 = "";

            try

            {

                foreach (CrystalDecisions.ReportAppServer.ReportDefModel.ReportObject rptObj1 in rptObjs)

                {

                    // look for sub report object and display info

                    if (rptObj1.Kind == CrReportObjectKindEnum.crReportObjectKindSubreport)

                    {

                       

 

 

                        CrystalDecisions.ReportAppServer.ReportDefModel.SubreportObject subObj1;

                        subObj1 = (CrystalDecisions.ReportAppServer.ReportDefModel.SubreportObject) rptObj1;

 

 

                        SubreportController subreportController = rptClientDoc.SubreportController;

                        var location =

                            ((CrystalDecisions.ReportAppServer.ReportDefModel.ISCRSubreportObject)(subObj1))

                                .SubreportLocation;

                        SubreportClientDocument subreportClientDocument =

                            subreportController.GetSubreport(subObj1.SubreportName);

 

 

                        textBox1 = textBox1 + "Imported: " + subObj1.SubreportLocation + "\n";

                    }

                }

            }

            catch (Exception ex)

            {

               

            }


Viewing all articles
Browse latest Browse all 3636

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>