on 02-07-2017 3:57 PM
Hi, I have a program che cycle on all subrerports of a reports and make some changes on a fields. After I save the report but only changes on first subrport are saved. The program is like follow code. The function : CheckFieldMapping remove some fields with report.ReportDefController.ReportObjectController.Remove(rptObject).
report = New CrystalDecisions.CrystalReports.Engine.ReportDocument
report.Load(strFile, CrystalDecisions.Shared.OpenReportMethod.OpenReportByDefault)
Dim rdc As ISCDReportClientDocument
rdc = report.ReportClientDocument
For Each subReportName As String In subReportNames
Dim subrptObj As SubreportClientDocument
subrptObj = dc.SubreportController.GetSubreport(subReportName)
CheckFieldMapping(rdc.DisplayName, CType(subrptObj, ISCRSubreportClientDocument)) subrptObj = Nothing
Next
subReportNames.RemoveAll()
rdc.Save()
report.SaveAs(strFile, False) rdc.Close() rdc = Nothing
Same idea ?
Hi Filippo,
Try saving the report after each subreport change and then compare output in CR Designer.
Or open the subreport rather than just loading it into memory...
Something like this:
foreach (CrystalDecisions.CrystalReports.Engine.Section section in rpt.ReportDefinition.Sections)
{
foreach (CrystalDecisions.CrystalReports.Engine.ReportObject reportObject in section.ReportObjects)
{
if (reportObject.Kind == ReportObjectKind.SubreportObject)
{
CrystalDecisions.CrystalReports.Engine.SubreportObject subReport = (CrystalDecisions.CrystalReports.Engine.SubreportObject)reportObject;
CrystalDecisions.CrystalReports.Engine.ReportDocument subDocument = subReport.OpenSubreport(subReport.SubreportName);
.... your code
subDocument.SetDataSource(ds);
}
}
}
Don
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.