Symptom
- The Crystal Reports SDK for VS .NET has limited ability when modifying charts
- For more details see KBase 1425910 - What are the limitations of modifying a chart in a Visual Studio .NET application?
Resolution
- Use the InProc RAS SDK for .NET exposes more APIs which allow chart modifications at runtime
- The following C# code will change the title of a chart in a report:
CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
ISCDReportClientDocument rcd;
rpt.Load(path);
rcd = rpt.ReportClientDocument;
CrystalDecisions.ReportAppServer.ReportDefModel.ChartObject oldChart;
CrystalDecisions.ReportAppServer.ReportDefModel.ChartObject newChart;
oldChart = (ChartObject)rcd.ReportDefController.ReportObjectController.GetReportObjectsByKind(CrReportObjectKindEnum.crReportObjectKindChart)[0];
newChart = (ChartObject)oldChart.Clone(true);
newChart.ChartStyle.TextOptions.Title = "My New Chart Title";
rcd.ReportDefController.ModifyChartObject(oldChart, newChart);
CrystalReportViewer1.ReportSource = rpt;
Keywords
Forum thread , KBA , BI-DEV-NET-SDK , .NET SDK / COM SDK , How To
Product
Crystal Reports 2008 V1 ; SAP Crystal Reports XI R2